summaryrefslogtreecommitdiff
path: root/cli/tests/unit/timers_test.ts
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2022-02-16 19:53:17 +0100
committerGitHub <noreply@github.com>2022-02-16 19:53:17 +0100
commit53088e16de9728696df12b04670a0f2d5203592b (patch)
tree74df68fc3f39db638db6431580d03c235a8f5ff4 /cli/tests/unit/timers_test.ts
parentb98afb59ae43b4fcfc2bf06e82942005d7f68c7b (diff)
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.
Diffstat (limited to 'cli/tests/unit/timers_test.ts')
-rw-r--r--cli/tests/unit/timers_test.ts8
1 files changed, 5 insertions, 3 deletions
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() {