diff options
| author | Luca Casonato <hello@lcas.dev> | 2022-02-16 19:53:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-16 19:53:17 +0100 |
| commit | 53088e16de9728696df12b04670a0f2d5203592b (patch) | |
| tree | 74df68fc3f39db638db6431580d03c235a8f5ff4 /cli/tests/unit | |
| parent | b98afb59ae43b4fcfc2bf06e82942005d7f68c7b (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')
| -rw-r--r-- | cli/tests/unit/http_test.ts | 2 | ||||
| -rw-r--r-- | cli/tests/unit/timers_test.ts | 8 |
2 files changed, 6 insertions, 4 deletions
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() { |
