From 53088e16de9728696df12b04670a0f2d5203592b Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 16 Feb 2022 19:53:17 +0100 Subject: feat(test): improved op sanitizer errors + traces (#13676) This commit improves the error messages for the `deno test` async op sanitizer. It does this in two ways: - it uses handwritten error messages for each op that could be leaking - it includes traces showing where each op was started This "async op tracing" functionality is a new feature in deno_core. It likely has a significant performance impact, which is why it is only enabled in tests. --- cli/tests/unit/http_test.ts | 2 +- cli/tests/unit/timers_test.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'cli/tests/unit') diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts index 2682ccee6..5ff1475b3 100644 --- a/cli/tests/unit/http_test.ts +++ b/cli/tests/unit/http_test.ts @@ -868,7 +868,7 @@ Deno.test( const readable = new ReadableStream({ async pull(controller) { client.close(); - await delay(100); + await delay(1000); controller.enqueue(new TextEncoder().encode( "written to the writable side of a TransformStream", )); diff --git a/cli/tests/unit/timers_test.ts b/cli/tests/unit/timers_test.ts index 7312a6440..e85a2effc 100644 --- a/cli/tests/unit/timers_test.ts +++ b/cli/tests/unit/timers_test.ts @@ -397,10 +397,12 @@ Deno.test(async function timerMaxCpuBug() { clearTimeout(setTimeout(() => {}, 1000)); // We can check this by counting how many ops have triggered in the interim. // Certainly less than 10 ops should have been dispatched in next 100 ms. - const { opsDispatched } = Deno.metrics(); + const { ops: pre } = Deno.metrics(); await delay(100); - const opsDispatched_ = Deno.metrics().opsDispatched; - assert(opsDispatched_ - opsDispatched < 10); + const { ops: post } = Deno.metrics(); + const before = pre.op_sleep.opsDispatched; + const after = post.op_sleep.opsDispatched; + assert(after - before < 10); }); Deno.test(async function timerOrdering() { -- cgit v1.2.3