From c92717a1a43d31951cd8a1161afb766ef339aa21 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Fri, 16 Feb 2024 10:49:42 -0700 Subject: chore(cli): pre-factor the sanitizer tests (#22436) Moving tests around so that we can make #22413 smaller --- tests/integration/test_tests.rs | 48 +++++++++------------- tests/testdata/test/exit_sanitizer.out | 38 ----------------- tests/testdata/test/exit_sanitizer.ts | 11 ----- .../ops_sanitizer_closed_inside_started_before.out | 19 --------- .../ops_sanitizer_closed_inside_started_before.ts | 5 --- .../test/ops_sanitizer_missing_details.out | 18 -------- .../testdata/test/ops_sanitizer_missing_details.ts | 10 ----- .../test/ops_sanitizer_multiple_timeout_tests.out | 45 -------------------- .../test/ops_sanitizer_multiple_timeout_tests.ts | 10 ----- ...s_sanitizer_multiple_timeout_tests_no_trace.out | 25 ----------- tests/testdata/test/ops_sanitizer_nexttick.out | 6 --- tests/testdata/test/ops_sanitizer_nexttick.ts | 11 ----- tests/testdata/test/ops_sanitizer_step_leak.out | 10 ----- tests/testdata/test/ops_sanitizer_step_leak.ts | 10 ----- .../test/ops_sanitizer_timeout_failure.out | 6 --- .../testdata/test/ops_sanitizer_timeout_failure.ts | 22 ---------- tests/testdata/test/ops_sanitizer_unstable.out | 22 ---------- tests/testdata/test/ops_sanitizer_unstable.ts | 9 ---- tests/testdata/test/resource_sanitizer.out | 20 --------- tests/testdata/test/resource_sanitizer.ts | 4 -- tests/testdata/test/sanitizer/exit_sanitizer.out | 38 +++++++++++++++++ tests/testdata/test/sanitizer/exit_sanitizer.ts | 11 +++++ .../ops_sanitizer_closed_inside_started_before.out | 19 +++++++++ .../ops_sanitizer_closed_inside_started_before.ts | 5 +++ .../ops_sanitizer_multiple_timeout_tests.out | 45 ++++++++++++++++++++ .../ops_sanitizer_multiple_timeout_tests.ts | 10 +++++ ...s_sanitizer_multiple_timeout_tests_no_trace.out | 25 +++++++++++ .../test/sanitizer/ops_sanitizer_nexttick.out | 6 +++ .../test/sanitizer/ops_sanitizer_nexttick.ts | 11 +++++ .../test/sanitizer/ops_sanitizer_step_leak.out | 10 +++++ .../test/sanitizer/ops_sanitizer_step_leak.ts | 10 +++++ .../sanitizer/ops_sanitizer_timeout_failure.out | 6 +++ .../sanitizer/ops_sanitizer_timeout_failure.ts | 22 ++++++++++ .../test/sanitizer/ops_sanitizer_unstable.out | 22 ++++++++++ .../test/sanitizer/ops_sanitizer_unstable.ts | 10 +++++ .../testdata/test/sanitizer/resource_sanitizer.out | 20 +++++++++ .../testdata/test/sanitizer/resource_sanitizer.ts | 4 ++ .../test/sanitizer/trace_ops_caught_error/main.out | 6 +++ .../test/sanitizer/trace_ops_caught_error/main.ts | 13 ++++++ .../testdata/test/trace_ops_caught_error/main.out | 6 --- tests/testdata/test/trace_ops_caught_error/main.ts | 12 ------ tests/unit_node/process_test.ts | 5 ++- 42 files changed, 316 insertions(+), 349 deletions(-) delete mode 100644 tests/testdata/test/exit_sanitizer.out delete mode 100644 tests/testdata/test/exit_sanitizer.ts delete mode 100644 tests/testdata/test/ops_sanitizer_closed_inside_started_before.out delete mode 100644 tests/testdata/test/ops_sanitizer_closed_inside_started_before.ts delete mode 100644 tests/testdata/test/ops_sanitizer_missing_details.out delete mode 100644 tests/testdata/test/ops_sanitizer_missing_details.ts delete mode 100644 tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out delete mode 100644 tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts delete mode 100644 tests/testdata/test/ops_sanitizer_multiple_timeout_tests_no_trace.out delete mode 100644 tests/testdata/test/ops_sanitizer_nexttick.out delete mode 100644 tests/testdata/test/ops_sanitizer_nexttick.ts delete mode 100644 tests/testdata/test/ops_sanitizer_step_leak.out delete mode 100644 tests/testdata/test/ops_sanitizer_step_leak.ts delete mode 100644 tests/testdata/test/ops_sanitizer_timeout_failure.out delete mode 100644 tests/testdata/test/ops_sanitizer_timeout_failure.ts delete mode 100644 tests/testdata/test/ops_sanitizer_unstable.out delete mode 100644 tests/testdata/test/ops_sanitizer_unstable.ts delete mode 100644 tests/testdata/test/resource_sanitizer.out delete mode 100644 tests/testdata/test/resource_sanitizer.ts create mode 100644 tests/testdata/test/sanitizer/exit_sanitizer.out create mode 100644 tests/testdata/test/sanitizer/exit_sanitizer.ts create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.out create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.ts create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.out create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.ts create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests_no_trace.out create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_nexttick.out create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_nexttick.ts create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_step_leak.out create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_step_leak.ts create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_timeout_failure.out create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_timeout_failure.ts create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_unstable.out create mode 100644 tests/testdata/test/sanitizer/ops_sanitizer_unstable.ts create mode 100644 tests/testdata/test/sanitizer/resource_sanitizer.out create mode 100644 tests/testdata/test/sanitizer/resource_sanitizer.ts create mode 100644 tests/testdata/test/sanitizer/trace_ops_caught_error/main.out create mode 100644 tests/testdata/test/sanitizer/trace_ops_caught_error/main.ts delete mode 100644 tests/testdata/test/trace_ops_caught_error/main.out delete mode 100644 tests/testdata/test/trace_ops_caught_error/main.ts diff --git a/tests/integration/test_tests.rs b/tests/integration/test_tests.rs index 2984941cd..f9b47fdbc 100644 --- a/tests/integration/test_tests.rs +++ b/tests/integration/test_tests.rs @@ -219,63 +219,55 @@ itest!(allow_none { }); itest!(ops_sanitizer_unstable { - args: "test --trace-ops test/ops_sanitizer_unstable.ts", + args: "test --trace-ops test/sanitizer/ops_sanitizer_unstable.ts", exit_code: 1, - output: "test/ops_sanitizer_unstable.out", + output: "test/sanitizer/ops_sanitizer_unstable.out", }); itest!(ops_sanitizer_timeout_failure { - args: "test test/ops_sanitizer_timeout_failure.ts", - output: "test/ops_sanitizer_timeout_failure.out", + args: "test test/sanitizer/ops_sanitizer_timeout_failure.ts", + output: "test/sanitizer/ops_sanitizer_timeout_failure.out", }); itest!(ops_sanitizer_multiple_timeout_tests { - args: "test --trace-ops test/ops_sanitizer_multiple_timeout_tests.ts", + args: + "test --trace-ops test/sanitizer/ops_sanitizer_multiple_timeout_tests.ts", exit_code: 1, - output: "test/ops_sanitizer_multiple_timeout_tests.out", + output: "test/sanitizer/ops_sanitizer_multiple_timeout_tests.out", }); itest!(ops_sanitizer_multiple_timeout_tests_no_trace { - args: "test test/ops_sanitizer_multiple_timeout_tests.ts", + args: "test test/sanitizer/ops_sanitizer_multiple_timeout_tests.ts", exit_code: 1, - output: "test/ops_sanitizer_multiple_timeout_tests_no_trace.out", + output: "test/sanitizer/ops_sanitizer_multiple_timeout_tests_no_trace.out", }); -itest!(trace_ops_catch_error { - args: "test -A --trace-ops test/trace_ops_caught_error/main.ts", +itest!(sanitizer_trace_ops_catch_error { + args: "test -A --trace-ops test/sanitizer/trace_ops_caught_error/main.ts", exit_code: 0, - output: "test/trace_ops_caught_error/main.out", + output: "test/sanitizer/trace_ops_caught_error/main.out", }); -// TODO(@littledivy): re-enable this test, recent optimizations made output non deterministic. -// https://github.com/denoland/deno/issues/14268 -// -// itest!(ops_sanitizer_missing_details { -// args: "test --allow-write --allow-read test/ops_sanitizer_missing_details.ts", -// exit_code: 1, -// output: "test/ops_sanitizer_missing_details.out", -// }); - itest!(ops_sanitizer_closed_inside_started_before { - args: "test --trace-ops test/ops_sanitizer_closed_inside_started_before.ts", + args: "test --trace-ops test/sanitizer/ops_sanitizer_closed_inside_started_before.ts", exit_code: 1, - output: "test/ops_sanitizer_closed_inside_started_before.out", + output: "test/sanitizer/ops_sanitizer_closed_inside_started_before.out", }); itest!(ops_sanitizer_nexttick { - args: "test --no-check test/ops_sanitizer_nexttick.ts", - output: "test/ops_sanitizer_nexttick.out", + args: "test --no-check test/sanitizer/ops_sanitizer_nexttick.ts", + output: "test/sanitizer/ops_sanitizer_nexttick.out", }); itest!(resource_sanitizer { - args: "test --allow-read test/resource_sanitizer.ts", + args: "test --allow-read test/sanitizer/resource_sanitizer.ts", exit_code: 1, - output: "test/resource_sanitizer.out", + output: "test/sanitizer/resource_sanitizer.out", }); itest!(exit_sanitizer { - args: "test test/exit_sanitizer.ts", - output: "test/exit_sanitizer.out", + args: "test test/sanitizer/exit_sanitizer.ts", + output: "test/sanitizer/exit_sanitizer.out", exit_code: 1, }); diff --git a/tests/testdata/test/exit_sanitizer.out b/tests/testdata/test/exit_sanitizer.out deleted file mode 100644 index 684001475..000000000 --- a/tests/testdata/test/exit_sanitizer.out +++ /dev/null @@ -1,38 +0,0 @@ -Check [WILDCARD]/test/exit_sanitizer.ts -running 3 tests from ./test/exit_sanitizer.ts -exit(0) ... FAILED ([WILDCARD]) -exit(1) ... FAILED ([WILDCARD]) -exit(2) ... FAILED ([WILDCARD]) - - ERRORS - -exit(0) => ./test/exit_sanitizer.ts:[WILDCARD] -error: Error: Test case attempted to exit with exit code: 0 - Deno.exit(0); - ^ - at [WILDCARD] - at [WILDCARD]/test/exit_sanitizer.ts:2:8 - -exit(1) => ./test/exit_sanitizer.ts:[WILDCARD] -error: Error: Test case attempted to exit with exit code: 1 - Deno.exit(1); - ^ - at [WILDCARD] - at [WILDCARD]/test/exit_sanitizer.ts:6:8 - -exit(2) => ./test/exit_sanitizer.ts:[WILDCARD] -error: Error: Test case attempted to exit with exit code: 2 - Deno.exit(2); - ^ - at [WILDCARD] - at [WILDCARD]/test/exit_sanitizer.ts:10:8 - - FAILURES - -exit(0) => ./test/exit_sanitizer.ts:[WILDCARD] -exit(1) => ./test/exit_sanitizer.ts:[WILDCARD] -exit(2) => ./test/exit_sanitizer.ts:[WILDCARD] - -FAILED | 0 passed | 3 failed ([WILDCARD]) - -error: Test failed diff --git a/tests/testdata/test/exit_sanitizer.ts b/tests/testdata/test/exit_sanitizer.ts deleted file mode 100644 index 186406a9d..000000000 --- a/tests/testdata/test/exit_sanitizer.ts +++ /dev/null @@ -1,11 +0,0 @@ -Deno.test("exit(0)", function () { - Deno.exit(0); -}); - -Deno.test("exit(1)", function () { - Deno.exit(1); -}); - -Deno.test("exit(2)", function () { - Deno.exit(2); -}); diff --git a/tests/testdata/test/ops_sanitizer_closed_inside_started_before.out b/tests/testdata/test/ops_sanitizer_closed_inside_started_before.out deleted file mode 100644 index 0a8cc2245..000000000 --- a/tests/testdata/test/ops_sanitizer_closed_inside_started_before.out +++ /dev/null @@ -1,19 +0,0 @@ -Check [WILDCARD]test/ops_sanitizer_closed_inside_started_before.ts -running 1 test from ./test/ops_sanitizer_closed_inside_started_before.ts -test 1 ... FAILED [WILDCARD] - - ERRORS - -test 1 => ./test/ops_sanitizer_closed_inside_started_before.ts:[WILDCARD] -error: Leaking async ops: - - 1 async operation to sleep for a duration was started before this test, but was 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: - at [WILDCARD] - at [WILDCARD]/tests/testdata/test/ops_sanitizer_closed_inside_started_before.ts:[WILDCARD] - - FAILURES - -test 1 => ./test/ops_sanitizer_closed_inside_started_before.ts:[WILDCARD] - -FAILED | 0 passed | 1 failed [WILDCARD] - -error: Test failed diff --git a/tests/testdata/test/ops_sanitizer_closed_inside_started_before.ts b/tests/testdata/test/ops_sanitizer_closed_inside_started_before.ts deleted file mode 100644 index 97d3d72c8..000000000 --- a/tests/testdata/test/ops_sanitizer_closed_inside_started_before.ts +++ /dev/null @@ -1,5 +0,0 @@ -const timer = setTimeout(() => {}, 10000000000); - -Deno.test("test 1", () => { - clearTimeout(timer); -}); diff --git a/tests/testdata/test/ops_sanitizer_missing_details.out b/tests/testdata/test/ops_sanitizer_missing_details.out deleted file mode 100644 index 36191912a..000000000 --- a/tests/testdata/test/ops_sanitizer_missing_details.out +++ /dev/null @@ -1,18 +0,0 @@ -Check [WILDCARD]test/ops_sanitizer_missing_details.ts -running 1 test from ./test/ops_sanitizer_missing_details.ts -test 1 ... FAILED [WILDCARD] - - ERRORS - -test 1 => ./test/ops_sanitizer_missing_details.ts:[WILDCARD] -error: Leaking async ops: - - 1 async operation to op_write was started in this test, but never completed. -To get more details where ops were leaked, run again with --trace-ops flag. - - FAILURES - -test 1 => ./test/ops_sanitizer_missing_details.ts:[WILDCARD] - -FAILED | 0 passed | 1 failed [WILDCARD] - -error: Test failed diff --git a/tests/testdata/test/ops_sanitizer_missing_details.ts b/tests/testdata/test/ops_sanitizer_missing_details.ts deleted file mode 100644 index 45fc89b42..000000000 --- a/tests/testdata/test/ops_sanitizer_missing_details.ts +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/denoland/deno/issues/13729 -// https://github.com/denoland/deno/issues/13938 -import { writeAll } from "../../../tests/util/std/streams/write_all.ts"; - -Deno.test("test 1", { permissions: { write: true, read: true } }, async () => { - const tmpFile = await Deno.makeTempFile(); - const file = await Deno.open(tmpFile, { write: true }); - const buf = new Uint8Array(new Array(1_000_000).fill(1)); - writeAll(file, buf); -}); diff --git a/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out b/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out deleted file mode 100644 index 6ebd28c51..000000000 --- a/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out +++ /dev/null @@ -1,45 +0,0 @@ -Check [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts -running 2 tests from ./test/ops_sanitizer_multiple_timeout_tests.ts -test 1 ... FAILED ([WILDCARD]) -test 2 ... FAILED ([WILDCARD]) - - ERRORS - -test 1 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] -error: 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:[WILDCARD]) - 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:[WILDCARD]) - at [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:8:27 - at [WILDCARD] - -test 2 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] -error: 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:[WILDCARD]) - 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:[WILDCARD]) - at [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:10:27 - at [WILDCARD] - - FAILURES - -test 1 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] -test 2 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] - -FAILED | 0 passed | 2 failed ([WILDCARD]) - -error: Test failed diff --git a/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts b/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts deleted file mode 100644 index 1f52d481f..000000000 --- a/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.ts +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/denoland/deno/issues/8965 - -function test() { - setTimeout(() => {}, 10000); - setTimeout(() => {}, 10001); -} - -Deno.test("test 1", () => test()); - -Deno.test("test 2", () => test()); diff --git a/tests/testdata/test/ops_sanitizer_multiple_timeout_tests_no_trace.out b/tests/testdata/test/ops_sanitizer_multiple_timeout_tests_no_trace.out deleted file mode 100644 index 1655c162f..000000000 --- a/tests/testdata/test/ops_sanitizer_multiple_timeout_tests_no_trace.out +++ /dev/null @@ -1,25 +0,0 @@ -Check [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts -running 2 tests from ./test/ops_sanitizer_multiple_timeout_tests.ts -test 1 ... FAILED ([WILDCARD]) -test 2 ... FAILED ([WILDCARD]) - - ERRORS - -test 1 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] -error: 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. -To get more details where ops were leaked, run again with --trace-ops flag. - -test 2 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] -error: 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. -To get more details where ops were leaked, run again with --trace-ops flag. - - FAILURES - -test 1 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] -test 2 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] - -FAILED | 0 passed | 2 failed ([WILDCARD]) - -error: Test failed diff --git a/tests/testdata/test/ops_sanitizer_nexttick.out b/tests/testdata/test/ops_sanitizer_nexttick.out deleted file mode 100644 index 44a8d13d5..000000000 --- a/tests/testdata/test/ops_sanitizer_nexttick.out +++ /dev/null @@ -1,6 +0,0 @@ -running 2 tests from ./test/ops_sanitizer_nexttick.ts -test 1 ... ok ([WILDCARD]) -test 2 ... ok ([WILDCARD]) - -ok | 2 passed | 0 failed ([WILDCARD]) - diff --git a/tests/testdata/test/ops_sanitizer_nexttick.ts b/tests/testdata/test/ops_sanitizer_nexttick.ts deleted file mode 100644 index 9ad3a7b28..000000000 --- a/tests/testdata/test/ops_sanitizer_nexttick.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { nextTick } from "node:process"; - -// https://github.com/denoland/deno_std/issues/1651 - -Deno.test("test 1", async () => { - await new Promise((resolve) => nextTick(resolve)); -}); - -Deno.test("test 2", async () => { - await new Promise((resolve) => nextTick(resolve)); -}); diff --git a/tests/testdata/test/ops_sanitizer_step_leak.out b/tests/testdata/test/ops_sanitizer_step_leak.out deleted file mode 100644 index 55c89582a..000000000 --- a/tests/testdata/test/ops_sanitizer_step_leak.out +++ /dev/null @@ -1,10 +0,0 @@ -Check [WILDCARD]/tests/testdata/test/ops_sanitizer_step_leak.ts -running 1 test from ./tests/testdata/test/ops_sanitizer_step_leak.ts -timeout ... - step ... ok [WILDCARD] -------- output ------- -done ------ output end ----- -timeout ... ok [WILDCARD] - -ok | 1 passed (1 step) | 0 failed [WILDCARD] \ No newline at end of file diff --git a/tests/testdata/test/ops_sanitizer_step_leak.ts b/tests/testdata/test/ops_sanitizer_step_leak.ts deleted file mode 100644 index 3fb9b397e..000000000 --- a/tests/testdata/test/ops_sanitizer_step_leak.ts +++ /dev/null @@ -1,10 +0,0 @@ -Deno.test("timeout", async (t) => { - const timer = setTimeout(() => { - console.log("timeout"); - }, 10000); - clearTimeout(timer); - await t.step("step", async () => { - await new Promise((resolve) => setTimeout(() => resolve(), 10)); - }); - console.log("done"); -}); diff --git a/tests/testdata/test/ops_sanitizer_timeout_failure.out b/tests/testdata/test/ops_sanitizer_timeout_failure.out deleted file mode 100644 index a4fbf0008..000000000 --- a/tests/testdata/test/ops_sanitizer_timeout_failure.out +++ /dev/null @@ -1,6 +0,0 @@ -Check [WILDCARD]/testdata/test/ops_sanitizer_timeout_failure.ts -running 1 test from ./test/ops_sanitizer_timeout_failure.ts -wait ... ok ([WILDCARD]) - -ok | 1 passed | 0 failed ([WILDCARD]) - diff --git a/tests/testdata/test/ops_sanitizer_timeout_failure.ts b/tests/testdata/test/ops_sanitizer_timeout_failure.ts deleted file mode 100644 index d40a5a258..000000000 --- a/tests/testdata/test/ops_sanitizer_timeout_failure.ts +++ /dev/null @@ -1,22 +0,0 @@ -let intervalHandle: number; -let firstIntervalPromise: Promise; - -addEventListener("load", () => { - firstIntervalPromise = new Promise((resolve) => { - let firstIntervalCalled = false; - intervalHandle = setInterval(() => { - if (!firstIntervalCalled) { - resolve(); - firstIntervalCalled = true; - } - }, 5); - }); -}); - -addEventListener("unload", () => { - clearInterval(intervalHandle); -}); - -Deno.test("wait", async function () { - await firstIntervalPromise; -}); diff --git a/tests/testdata/test/ops_sanitizer_unstable.out b/tests/testdata/test/ops_sanitizer_unstable.out deleted file mode 100644 index a4f47a749..000000000 --- a/tests/testdata/test/ops_sanitizer_unstable.out +++ /dev/null @@ -1,22 +0,0 @@ -Check [WILDCARD]/testdata/test/ops_sanitizer_unstable.ts -running 2 tests from ./test/ops_sanitizer_unstable.ts -no-op ... ok ([WILDCARD]) -leak interval ... FAILED ([WILDCARD]) - - ERRORS - -leak interval => ./test/ops_sanitizer_unstable.ts:[WILDCARD] -error: Leaking async ops: - - 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 fn ([WILDCARD]/testdata/test/ops_sanitizer_unstable.ts:7:5) - at [WILDCARD] - - FAILURES - -leak interval => ./test/ops_sanitizer_unstable.ts:[WILDCARD] - -FAILED | 1 passed | 1 failed ([WILDCARD]) - -error: Test failed diff --git a/tests/testdata/test/ops_sanitizer_unstable.ts b/tests/testdata/test/ops_sanitizer_unstable.ts deleted file mode 100644 index d1b554adf..000000000 --- a/tests/testdata/test/ops_sanitizer_unstable.ts +++ /dev/null @@ -1,9 +0,0 @@ -Deno.test("no-op", function () {}); -Deno.test({ - name: "leak interval", - // regression test for sanitizer errors being swallowed with permissions. - permissions: {}, - fn() { - setInterval(function () {}, 100000); - }, -}); diff --git a/tests/testdata/test/resource_sanitizer.out b/tests/testdata/test/resource_sanitizer.out deleted file mode 100644 index 655dd2a17..000000000 --- a/tests/testdata/test/resource_sanitizer.out +++ /dev/null @@ -1,20 +0,0 @@ -Check [WILDCARD]/test/resource_sanitizer.ts -running 1 test from ./test/resource_sanitizer.ts -leak ... FAILED ([WILDCARD]) - - ERRORS - -leak => ./test/resource_sanitizer.ts:[WILDCARD] -error: Leaking resources: -[UNORDERED_START] - - The stdin pipe was opened before the test started, but was closed during the test. Do not close resources in a test that were not created during that test. - - A file was opened during the test, but not closed during the test. Close the file handle by calling `file.close()`. -[UNORDERED_END] - - FAILURES - -leak => ./test/resource_sanitizer.ts:[WILDCARD] - -FAILED | 0 passed | 1 failed ([WILDCARD]) - -error: Test failed diff --git a/tests/testdata/test/resource_sanitizer.ts b/tests/testdata/test/resource_sanitizer.ts deleted file mode 100644 index 93c9222c5..000000000 --- a/tests/testdata/test/resource_sanitizer.ts +++ /dev/null @@ -1,4 +0,0 @@ -Deno.test("leak", function () { - Deno.openSync("run/001_hello.js"); - Deno.stdin.close(); -}); diff --git a/tests/testdata/test/sanitizer/exit_sanitizer.out b/tests/testdata/test/sanitizer/exit_sanitizer.out new file mode 100644 index 000000000..305d51cc8 --- /dev/null +++ b/tests/testdata/test/sanitizer/exit_sanitizer.out @@ -0,0 +1,38 @@ +Check [WILDCARD]/exit_sanitizer.ts +running 3 tests from [WILDCARD]/exit_sanitizer.ts +exit(0) ... FAILED ([WILDCARD]) +exit(1) ... FAILED ([WILDCARD]) +exit(2) ... FAILED ([WILDCARD]) + + ERRORS + +exit(0) => [WILDCARD]/exit_sanitizer.ts:[WILDCARD] +error: Error: Test case attempted to exit with exit code: 0 + Deno.exit(0); + ^ + at [WILDCARD] + at [WILDCARD]/exit_sanitizer.ts:2:8 + +exit(1) => [WILDCARD]/exit_sanitizer.ts:[WILDCARD] +error: Error: Test case attempted to exit with exit code: 1 + Deno.exit(1); + ^ + at [WILDCARD] + at [WILDCARD]/exit_sanitizer.ts:6:8 + +exit(2) => [WILDCARD]/exit_sanitizer.ts:[WILDCARD] +error: Error: Test case attempted to exit with exit code: 2 + Deno.exit(2); + ^ + at [WILDCARD] + at [WILDCARD]/exit_sanitizer.ts:10:8 + + FAILURES + +exit(0) => [WILDCARD]/exit_sanitizer.ts:[WILDCARD] +exit(1) => [WILDCARD]/exit_sanitizer.ts:[WILDCARD] +exit(2) => [WILDCARD]/exit_sanitizer.ts:[WILDCARD] + +FAILED | 0 passed | 3 failed ([WILDCARD]) + +error: Test failed diff --git a/tests/testdata/test/sanitizer/exit_sanitizer.ts b/tests/testdata/test/sanitizer/exit_sanitizer.ts new file mode 100644 index 000000000..186406a9d --- /dev/null +++ b/tests/testdata/test/sanitizer/exit_sanitizer.ts @@ -0,0 +1,11 @@ +Deno.test("exit(0)", function () { + Deno.exit(0); +}); + +Deno.test("exit(1)", function () { + Deno.exit(1); +}); + +Deno.test("exit(2)", function () { + Deno.exit(2); +}); 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 new file mode 100644 index 000000000..823f4704e --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.out @@ -0,0 +1,19 @@ +Check [WILDCARD]/ops_sanitizer_closed_inside_started_before.ts +running 1 test from [WILDCARD]/ops_sanitizer_closed_inside_started_before.ts +test 1 ... FAILED [WILDCARD] + + ERRORS + +test 1 => [WILDCARD]/ops_sanitizer_closed_inside_started_before.ts:[WILDCARD] +error: Leaking async ops: + - 1 async operation to sleep for a duration was started before this test, but was 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: + at [WILDCARD] + at [WILDCARD]/ops_sanitizer_closed_inside_started_before.ts:[WILDCARD] + + FAILURES + +test 1 => [WILDCARD]/ops_sanitizer_closed_inside_started_before.ts:[WILDCARD] + +FAILED | 0 passed | 1 failed [WILDCARD] + +error: Test failed diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.ts b/tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.ts new file mode 100644 index 000000000..97d3d72c8 --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_closed_inside_started_before.ts @@ -0,0 +1,5 @@ +const timer = setTimeout(() => {}, 10000000000); + +Deno.test("test 1", () => { + clearTimeout(timer); +}); diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.out b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.out new file mode 100644 index 000000000..6af59da90 --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.out @@ -0,0 +1,45 @@ +Check [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts +running 2 tests from [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts +test 1 ... FAILED ([WILDCARD]) +test 2 ... FAILED ([WILDCARD]) + + ERRORS + +test 1 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] +error: 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]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD]) + at [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:8:27 + at [WILDCARD] + + 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] + +test 2 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] +error: 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]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD]) + at [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:10:27 + at [WILDCARD] + + 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] + + FAILURES + +test 1 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] +test 2 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] + +FAILED | 0 passed | 2 failed ([WILDCARD]) + +error: Test failed diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.ts b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.ts new file mode 100644 index 000000000..1f52d481f --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests.ts @@ -0,0 +1,10 @@ +// https://github.com/denoland/deno/issues/8965 + +function test() { + setTimeout(() => {}, 10000); + setTimeout(() => {}, 10001); +} + +Deno.test("test 1", () => test()); + +Deno.test("test 2", () => test()); 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 new file mode 100644 index 000000000..ae5f68f2f --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_multiple_timeout_tests_no_trace.out @@ -0,0 +1,25 @@ +Check [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts +running 2 tests from [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts +test 1 ... FAILED ([WILDCARD]) +test 2 ... FAILED ([WILDCARD]) + + ERRORS + +test 1 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] +error: 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. +To get more details where ops were leaked, run again with --trace-ops flag. + +test 2 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] +error: 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. +To get more details where ops were leaked, run again with --trace-ops flag. + + FAILURES + +test 1 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] +test 2 => [WILDCARD]/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] + +FAILED | 0 passed | 2 failed ([WILDCARD]) + +error: Test failed diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_nexttick.out b/tests/testdata/test/sanitizer/ops_sanitizer_nexttick.out new file mode 100644 index 000000000..407699b6a --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_nexttick.out @@ -0,0 +1,6 @@ +running 2 tests from [WILDCARD]/ops_sanitizer_nexttick.ts +test 1 ... ok ([WILDCARD]) +test 2 ... ok ([WILDCARD]) + +ok | 2 passed | 0 failed ([WILDCARD]) + diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_nexttick.ts b/tests/testdata/test/sanitizer/ops_sanitizer_nexttick.ts new file mode 100644 index 000000000..9ad3a7b28 --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_nexttick.ts @@ -0,0 +1,11 @@ +import { nextTick } from "node:process"; + +// https://github.com/denoland/deno_std/issues/1651 + +Deno.test("test 1", async () => { + await new Promise((resolve) => nextTick(resolve)); +}); + +Deno.test("test 2", async () => { + await new Promise((resolve) => nextTick(resolve)); +}); diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_step_leak.out b/tests/testdata/test/sanitizer/ops_sanitizer_step_leak.out new file mode 100644 index 000000000..be88a6e1d --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_step_leak.out @@ -0,0 +1,10 @@ +Check [WILDCARD]/ops_sanitizer_step_leak.ts +running 1 test from [WILDCARD]/ops_sanitizer_step_leak.ts +timeout ... + step ... ok [WILDCARD] +------- output ------- +done +----- output end ----- +timeout ... ok [WILDCARD] + +ok | 1 passed (1 step) | 0 failed [WILDCARD] \ No newline at end of file diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_step_leak.ts b/tests/testdata/test/sanitizer/ops_sanitizer_step_leak.ts new file mode 100644 index 000000000..3fb9b397e --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_step_leak.ts @@ -0,0 +1,10 @@ +Deno.test("timeout", async (t) => { + const timer = setTimeout(() => { + console.log("timeout"); + }, 10000); + clearTimeout(timer); + await t.step("step", async () => { + await new Promise((resolve) => setTimeout(() => resolve(), 10)); + }); + console.log("done"); +}); diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_timeout_failure.out b/tests/testdata/test/sanitizer/ops_sanitizer_timeout_failure.out new file mode 100644 index 000000000..e6e527112 --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_timeout_failure.out @@ -0,0 +1,6 @@ +Check [WILDCARD]/ops_sanitizer_timeout_failure.ts +running 1 test from [WILDCARD]/ops_sanitizer_timeout_failure.ts +wait ... ok ([WILDCARD]) + +ok | 1 passed | 0 failed ([WILDCARD]) + diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_timeout_failure.ts b/tests/testdata/test/sanitizer/ops_sanitizer_timeout_failure.ts new file mode 100644 index 000000000..d40a5a258 --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_timeout_failure.ts @@ -0,0 +1,22 @@ +let intervalHandle: number; +let firstIntervalPromise: Promise; + +addEventListener("load", () => { + firstIntervalPromise = new Promise((resolve) => { + let firstIntervalCalled = false; + intervalHandle = setInterval(() => { + if (!firstIntervalCalled) { + resolve(); + firstIntervalCalled = true; + } + }, 5); + }); +}); + +addEventListener("unload", () => { + clearInterval(intervalHandle); +}); + +Deno.test("wait", async function () { + await firstIntervalPromise; +}); diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_unstable.out b/tests/testdata/test/sanitizer/ops_sanitizer_unstable.out new file mode 100644 index 000000000..f7c391b7c --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_unstable.out @@ -0,0 +1,22 @@ +Check [WILDCARD]/ops_sanitizer_unstable.ts +running 2 tests from [WILDCARD]/ops_sanitizer_unstable.ts +no-op ... ok ([WILDCARD]) +leak interval ... FAILED ([WILDCARD]) + + ERRORS + +leak interval => [WILDCARD]/ops_sanitizer_unstable.ts:[WILDCARD] +error: Leaking async ops: + - 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 fn ([WILDCARD]/ops_sanitizer_unstable.ts:[WILDCARD]) + at [WILDCARD] + + FAILURES + +leak interval => [WILDCARD]/ops_sanitizer_unstable.ts:[WILDCARD] + +FAILED | 1 passed | 1 failed ([WILDCARD]) + +error: Test failed diff --git a/tests/testdata/test/sanitizer/ops_sanitizer_unstable.ts b/tests/testdata/test/sanitizer/ops_sanitizer_unstable.ts new file mode 100644 index 000000000..1deb1d5a7 --- /dev/null +++ b/tests/testdata/test/sanitizer/ops_sanitizer_unstable.ts @@ -0,0 +1,10 @@ +Deno.test("no-op", function () {}); +Deno.test({ + name: "leak interval", + // regression test for sanitizer errors being swallowed with permissions. + // https://github.com/denoland/deno/pull/18550 + permissions: {}, + fn() { + setInterval(function () {}, 100000); + }, +}); diff --git a/tests/testdata/test/sanitizer/resource_sanitizer.out b/tests/testdata/test/sanitizer/resource_sanitizer.out new file mode 100644 index 000000000..50f98511c --- /dev/null +++ b/tests/testdata/test/sanitizer/resource_sanitizer.out @@ -0,0 +1,20 @@ +Check [WILDCARD]/resource_sanitizer.ts +running 1 test from [WILDCARD]/resource_sanitizer.ts +leak ... FAILED ([WILDCARD]) + + ERRORS + +leak => [WILDCARD]/resource_sanitizer.ts:[WILDCARD] +error: Leaking resources: +[UNORDERED_START] + - The stdin pipe was opened before the test started, but was closed during the test. Do not close resources in a test that were not created during that test. + - A file was opened during the test, but not closed during the test. Close the file handle by calling `file.close()`. +[UNORDERED_END] + + FAILURES + +leak => [WILDCARD]/resource_sanitizer.ts:[WILDCARD] + +FAILED | 0 passed | 1 failed ([WILDCARD]) + +error: Test failed diff --git a/tests/testdata/test/sanitizer/resource_sanitizer.ts b/tests/testdata/test/sanitizer/resource_sanitizer.ts new file mode 100644 index 000000000..93c9222c5 --- /dev/null +++ b/tests/testdata/test/sanitizer/resource_sanitizer.ts @@ -0,0 +1,4 @@ +Deno.test("leak", function () { + Deno.openSync("run/001_hello.js"); + Deno.stdin.close(); +}); diff --git a/tests/testdata/test/sanitizer/trace_ops_caught_error/main.out b/tests/testdata/test/sanitizer/trace_ops_caught_error/main.out new file mode 100644 index 000000000..4e591adf1 --- /dev/null +++ b/tests/testdata/test/sanitizer/trace_ops_caught_error/main.out @@ -0,0 +1,6 @@ +Check file:///[WILDCARD]/trace_ops_caught_error/main.ts +running 1 test from [WILDCARD]/trace_ops_caught_error/main.ts +handle thrown error in async function ... ok ([WILDCARD]) + +ok | 1 passed | 0 failed ([WILDCARD]) + diff --git a/tests/testdata/test/sanitizer/trace_ops_caught_error/main.ts b/tests/testdata/test/sanitizer/trace_ops_caught_error/main.ts new file mode 100644 index 000000000..043018688 --- /dev/null +++ b/tests/testdata/test/sanitizer/trace_ops_caught_error/main.ts @@ -0,0 +1,13 @@ +// https://github.com/denoland/deno/pull/16970 +Deno.test("handle thrown error in async function", async () => { + const dirPath = Deno.makeTempDirSync(); + const filePath = `${dirPath}/file.txt`; + try { + await Deno.stat(filePath); + } catch { + await Deno.writeTextFile(filePath, ""); + } finally { + await Deno.remove(filePath); + await Deno.remove(dirPath); + } +}); diff --git a/tests/testdata/test/trace_ops_caught_error/main.out b/tests/testdata/test/trace_ops_caught_error/main.out deleted file mode 100644 index 192ed3a6d..000000000 --- a/tests/testdata/test/trace_ops_caught_error/main.out +++ /dev/null @@ -1,6 +0,0 @@ -Check file:///[WILDCARD]/trace_ops_caught_error/main.ts -running 1 test from ./test/trace_ops_caught_error/main.ts -handle thrown error in async function ... ok ([WILDCARD]) - -ok | 1 passed | 0 failed ([WILDCARD]) - diff --git a/tests/testdata/test/trace_ops_caught_error/main.ts b/tests/testdata/test/trace_ops_caught_error/main.ts deleted file mode 100644 index 8194a8b2a..000000000 --- a/tests/testdata/test/trace_ops_caught_error/main.ts +++ /dev/null @@ -1,12 +0,0 @@ -Deno.test("handle thrown error in async function", async () => { - const dirPath = Deno.makeTempDirSync(); - const filePath = `${dirPath}/file.txt`; - try { - await Deno.stat(filePath); - } catch { - await Deno.writeTextFile(filePath, ""); - } finally { - await Deno.remove(filePath); - await Deno.remove(dirPath); - } -}); diff --git a/tests/unit_node/process_test.ts b/tests/unit_node/process_test.ts index bc2ff640e..bff3c6641 100644 --- a/tests/unit_node/process_test.ts +++ b/tests/unit_node/process_test.ts @@ -226,6 +226,7 @@ Deno.test({ }, }); +// Only supported on Windows (but won't throw anywhere) Deno.test({ name: "process.on SIGBREAK doesn't throw", fn() { @@ -235,9 +236,9 @@ Deno.test({ }, }); +// Not supported on Windows (but won't throw anywhere) Deno.test({ - name: "process.on SIGTERM doesn't throw on windows", - ignore: Deno.build.os !== "windows", + name: "process.on SIGTERM doesn't throw", fn() { const listener = () => {}; process.on("SIGTERM", listener); -- cgit v1.2.3