diff options
Diffstat (limited to 'tests')
9 files changed, 45 insertions, 12 deletions
diff --git a/tests/integration/test_tests.rs b/tests/integration/test_tests.rs index cf02872e4..cd85fd102 100644 --- a/tests/integration/test_tests.rs +++ b/tests/integration/test_tests.rs @@ -265,6 +265,12 @@ itest!(resource_sanitizer { output: "test/sanitizer/resource_sanitizer.out", }); +itest!(ops_sanitizer_tcp { + args: "test --allow-net --trace-leaks test/sanitizer/ops_sanitizer_tcp.ts", + exit_code: 1, + output: "test/sanitizer/ops_sanitizer_tcp.out", +}); + itest!(exit_sanitizer { args: "test test/sanitizer/exit_sanitizer.ts", output: "test/sanitizer/exit_sanitizer.out", diff --git a/tests/testdata/run/worker_drop_handle_race.js.out b/tests/testdata/run/worker_drop_handle_race.js.out index 451c3af3d..0820f164e 100644 --- a/tests/testdata/run/worker_drop_handle_race.js.out +++ b/tests/testdata/run/worker_drop_handle_race.js.out @@ -2,7 +2,6 @@ error: Uncaught (in worker "") Error throw new Error(); ^ at [WILDCARD]/workers/drop_handle_race.js:2:9 - at Object.action (ext:deno_web/02_timers.js:[WILDCARD]) - at handleTimerMacrotask (ext:deno_web/02_timers.js:[WILDCARD]) + at [WILDCARD] error: Uncaught (in promise) Error: Unhandled error in child worker. at Worker.#pollControl [WILDCARD] diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.out b/tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.out index 8346ba526..ffccd8422 100644 --- a/tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.out +++ b/tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.out @@ -6,7 +6,7 @@ test 1 ... FAILED [WILDCARD] test 1 => [WILDCARD]/ops_sanitizer_closed_inside_started_before.ts:[WILDCARD] error: Leaks detected: - - An async operation to sleep for a duration was started before the test, but completed during the test. Async operations should not complete in a test if they were not started in that test. This is often caused by not cancelling a `setTimeout` or `setInterval` call. The operation was started here: + - A timer was started before the test, but completed during the test. Intervals and timers should not complete in a test if they were not started in that test. This is often caused by not calling `clearTimeout`. The operation was started here: at [WILDCARD] at [WILDCARD]/ops_sanitizer_closed_inside_started_before.ts:[WILDCARD] diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.out b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.out index 57801c5c8..38d7fbb52 100644 --- a/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.out +++ b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.out @@ -7,13 +7,13 @@ test 2 ... FAILED ([WILDCARD]) test 1 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] error: Leaks detected: - - An 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: + - A timer was started in this test, but never completed. This is often caused by not calling `clearTimeout`. The operation was started here: at [WILDCARD] at setTimeout ([WILDCARD]) at test ([WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD]) at [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:8:27 at [WILDCARD] - - An 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: + - A timer was started in this test, but never completed. This is often caused by not calling `clearTimeout`. The operation was started here: at [WILDCARD] at setTimeout ([WILDCARD]) at test ([WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD]) @@ -22,13 +22,13 @@ error: Leaks detected: test 2 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] error: Leaks detected: - - An 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: + - A timer was started in this test, but never completed. This is often caused by not calling `clearTimeout`. The operation was started here: at [WILDCARD] at setTimeout ([WILDCARD]) at test ([WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD]) at [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:10:27 at [WILDCARD] - - An 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: + - A timer was started in this test, but never completed. This is often caused by not calling `clearTimeout`. The operation was started here: at [WILDCARD] at setTimeout ([WILDCARD]) at test ([WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD]) diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests_no_trace.out b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests_no_trace.out index 3a08089b7..c87cd0025 100644 --- a/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests_no_trace.out +++ b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests_no_trace.out @@ -7,12 +7,12 @@ test 2 ... FAILED ([WILDCARD]) test 1 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] error: Leaks detected: - - 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. + - 2 timers were started in this test, but never completed. This is often caused by not calling `clearTimeout`. To get more details where leaks occurred, run again with the --trace-leaks flag. test 2 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] error: Leaks detected: - - 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. + - 2 timers were started in this test, but never completed. This is often caused by not calling `clearTimeout`. To get more details where leaks occurred, run again with the --trace-leaks flag. FAILURES diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_tcp.out b/tests/testdata/test/sanitizer/ops_sanitizer_tcp.out new file mode 100644 index 000000000..7b5660379 --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_tcp.out @@ -0,0 +1,24 @@ +Check [WILDCARD]/ops_sanitizer_tcp.ts +running 1 test from [WILDCARD]/ops_sanitizer_tcp.ts +testLeakTcpOps ... FAILED ([WILDCARD]) + + ERRORS + +testLeakTcpOps => [WILDCARD]/ops_sanitizer_tcp.ts:[WILDCARD] +error: Leaks detected: + - A TCP listener was opened during the test, but not closed during the test. Close the TCP listener by calling `tcpListener.close()`. + - An async operation to accept a TCP stream was started in this test, but never completed. This is often caused by not closing a `Deno.Listener`. The operation was started here: + at op_net_accept_tcp ([WILDCARD]) + at Listener.accept ([WILDCARD]) + at testLeakTcpOps ([WILDCARD]) + at innerWrapped ([WILDCARD]) + at exitSanitizer ([WILDCARD]) + at outerWrapped ([WILDCARD]) + + FAILURES + +testLeakTcpOps => [WILDCARD]/ops_sanitizer_tcp.ts:[WILDCARD] + +FAILED | 0 passed | 1 failed ([WILDCARD]) + +error: Test failed diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_tcp.ts b/tests/testdata/test/sanitizer/ops_sanitizer_tcp.ts new file mode 100644 index 000000000..ec2df9fd5 --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_tcp.ts @@ -0,0 +1,4 @@ +Deno.test(function testLeakTcpOps() { + const listener1 = Deno.listen({ port: 0 }); + listener1.accept(); +}); diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_unstable.out b/tests/testdata/test/sanitizer/ops_sanitizer_unstable.out index 1e0fa1d0d..115d8cefa 100644 --- a/tests/testdata/test/sanitizer/ops_sanitizer_unstable.out +++ b/tests/testdata/test/sanitizer/ops_sanitizer_unstable.out @@ -9,7 +9,7 @@ leak interval ... FAILED ([WILDCARD]) leak interval => [WILDCARD]/ops_sanitizer_unstable.ts:[WILDCARD] error: Leaks detected: - - An 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: + - An interval was started in this test, but never completed. This is often caused by not calling `clearInterval`. The operation was started here: at [WILDCARD] at setInterval ([WILDCARD]) at fn ([WILDCARD]/ops_sanitizer_unstable.ts:[WILDCARD]) diff --git a/tests/unit/timers_test.ts b/tests/unit/timers_test.ts index 17b137231..9e3b082dd 100644 --- a/tests/unit/timers_test.ts +++ b/tests/unit/timers_test.ts @@ -238,8 +238,8 @@ Deno.test(async function callbackTakesLongerThanInterval() { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 300); timeEndOfFirstCallback = Date.now(); } else { - // Second callback - assert(Date.now() - 100 >= timeEndOfFirstCallback); + // Second callback should be nearly instantaneous + assert(Date.now() - timeEndOfFirstCallback < 10); clearInterval(interval); resolve(); } |