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/testdata | |
| 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/testdata')
4 files changed, 34 insertions, 56 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); }); |
