diff options
author | Luca Casonato <hello@lcas.dev> | 2023-09-16 07:48:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-16 07:48:31 +0200 |
commit | 430b63c2c4d6567a77e77980058ef13b45a9f30e (patch) | |
tree | 714fef4813a5614ccdd17b681f30e3bd0b4057bd /cli/tests/unit_node/child_process_test.ts | |
parent | bf0760411336ce5ebb1c103f766c8154af478414 (diff) |
perf: improve async op santizer speed and accuracy (#20501)
This commit improves async op sanitizer speed by only delaying metrics
collection if there are pending ops. This
results in a speedup of around 30% for small CPU bound unit tests.
It performs this check and possible delay on every collection now,
fixing an issue with parent test leaks into steps.
Diffstat (limited to 'cli/tests/unit_node/child_process_test.ts')
-rw-r--r-- | cli/tests/unit_node/child_process_test.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/tests/unit_node/child_process_test.ts b/cli/tests/unit_node/child_process_test.ts index a282977e0..8d1c9a6b7 100644 --- a/cli/tests/unit_node/child_process_test.ts +++ b/cli/tests/unit_node/child_process_test.ts @@ -497,9 +497,15 @@ Deno.test({ ); const childProcess = spawn(Deno.execPath(), ["run", script]); const p = withTimeout(); + const pStdout = withTimeout(); + const pStderr = withTimeout(); childProcess.on("exit", () => p.resolve()); + childProcess.stdout.on("close", () => pStdout.resolve()); + childProcess.stderr.on("close", () => pStderr.resolve()); childProcess.kill("SIGKILL"); await p; + await pStdout; + await pStderr; assert(childProcess.killed); assertEquals(childProcess.signalCode, "SIGKILL"); assertExists(childProcess.exitCode); @@ -633,9 +639,15 @@ Deno.test({ // Spawn an infinite cat const cp = spawn("cat", ["-"]); const p = withTimeout(); + const pStdout = withTimeout(); + const pStderr = withTimeout(); cp.on("exit", () => p.resolve()); + cp.stdout.on("close", () => pStdout.resolve()); + cp.stderr.on("close", () => pStderr.resolve()); cp.kill("SIGIOT"); await p; + await pStdout; + await pStderr; assert(cp.killed); assertEquals(cp.signalCode, "SIGIOT"); }, |