diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out | 62 | ||||
-rw-r--r-- | cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts | 4 | ||||
-rw-r--r-- | cli/tests/testdata/test/ops_sanitizer_unstable.out | 22 | ||||
-rw-r--r-- | cli/tests/testdata/test/ops_sanitizer_unstable.ts | 2 | ||||
-rw-r--r-- | cli/tests/unit/http_test.ts | 2 | ||||
-rw-r--r-- | cli/tests/unit/timers_test.ts | 8 |
6 files changed, 40 insertions, 60 deletions
diff --git a/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out b/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out index 1981a2500..acab794ab 100644 --- a/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out +++ b/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out @@ -6,45 +6,35 @@ test test 2 ... FAILED ([WILDCARD]) failures: test 1 -AssertionError: Test case is leaking async ops. -Before: - - dispatched: 0 - - completed: 0 -After: - - dispatched: [WILDCARD] - - completed: [WILDCARD] -Ops: - op_sleep: - Before: - - dispatched: 0 - - completed: 0 - After: - - dispatched: [WILDCARD] - - completed: [WILDCARD] - -Make sure to await all promises returned from Deno APIs before -finishing test case. +Test case is leaking async ops. + +- 2 async operations to sleep for a duration were started in this test, but never completed. This is often caused by not cancelling a `setTimeout` or `setInterval` call. The operations were started here: + at [WILDCARD] + at setTimeout ([WILDCARD]) + at test ([WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:4:3) + at [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:8:27 + at [WILDCARD] + + at [WILDCARD] + at setTimeout ([WILDCARD]) + at test ([WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:5:3) + at [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:8:27 at [WILDCARD] test 2 -AssertionError: Test case is leaking async ops. -Before: - - dispatched: [WILDCARD] - - completed: [WILDCARD] -After: - - dispatched: [WILDCARD] - - completed: [WILDCARD] -Ops: - op_sleep: - Before: - - dispatched: [WILDCARD] - - completed: [WILDCARD] - After: - - dispatched: [WILDCARD] - - completed: [WILDCARD] - -Make sure to await all promises returned from Deno APIs before -finishing test case. +Test case is leaking async ops. + +- 2 async operations to sleep for a duration were started in this test, but never completed. This is often caused by not cancelling a `setTimeout` or `setInterval` call. The operations were started here: + at [WILDCARD] + at setTimeout ([WILDCARD]) + at test ([WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:4:3) + at [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:10:27 + at [WILDCARD] + + at [WILDCARD] + at setTimeout ([WILDCARD]) + at test ([WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:5:3) + at [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:10:27 at [WILDCARD] failures: diff --git a/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts b/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts index f30773cf2..1f52d481f 100644 --- a/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts +++ b/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts @@ -5,6 +5,6 @@ function test() { setTimeout(() => {}, 10001); } -Deno.test("test 1", test); +Deno.test("test 1", () => test()); -Deno.test("test 2", test); +Deno.test("test 2", () => test()); diff --git a/cli/tests/testdata/test/ops_sanitizer_unstable.out b/cli/tests/testdata/test/ops_sanitizer_unstable.out index 9d6a903e1..84ea10501 100644 --- a/cli/tests/testdata/test/ops_sanitizer_unstable.out +++ b/cli/tests/testdata/test/ops_sanitizer_unstable.out @@ -6,24 +6,12 @@ test leak interval ... FAILED ([WILDCARD]) failures: leak interval -AssertionError: Test case is leaking async ops. -Before: - - dispatched: 1 - - completed: 1 -After: - - dispatched: [WILDCARD] - - completed: [WILDCARD] -Ops: - op_sleep: - Before: - - dispatched: 1 - - completed: 1 - After: - - dispatched: [WILDCARD] - - completed: [WILDCARD] +Test case is leaking async ops. -Make sure to await all promises returned from Deno APIs before -finishing test case. +- 1 async operation to sleep for a duration was started in this test, but never completed. This is often caused by not cancelling a `setTimeout` or `setInterval` call. The operation was started here: + at [WILDCARD] + at setInterval ([WILDCARD]) + at [WILDCARD]/testdata/test/ops_sanitizer_unstable.ts:3:3 at [WILDCARD] failures: diff --git a/cli/tests/testdata/test/ops_sanitizer_unstable.ts b/cli/tests/testdata/test/ops_sanitizer_unstable.ts index 92f7bb888..4f409e73c 100644 --- a/cli/tests/testdata/test/ops_sanitizer_unstable.ts +++ b/cli/tests/testdata/test/ops_sanitizer_unstable.ts @@ -1,4 +1,4 @@ Deno.test("no-op", function () {}); Deno.test("leak interval", function () { - setInterval(function () {}); + setInterval(function () {}, 100000); }); 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() { |