mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
fix(runtime/testing): false positive for timers when an error is thrown (#9553)
This commit is contained in:
parent
b47f9cee8c
commit
eefd522f04
4 changed files with 48 additions and 5 deletions
|
@ -2402,6 +2402,12 @@ mod integration {
|
||||||
output: "deno_test.out",
|
output: "deno_test.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(deno_test_finally_cleartimeout {
|
||||||
|
args: "test test_finally_cleartimeout.ts",
|
||||||
|
exit_code: 1,
|
||||||
|
output: "test_finally_cleartimeout.out",
|
||||||
|
});
|
||||||
|
|
||||||
itest!(deno_test_unresolved_promise {
|
itest!(deno_test_unresolved_promise {
|
||||||
args: "test test_unresolved_promise.js",
|
args: "test test_unresolved_promise.js",
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
|
|
23
cli/tests/test_finally_cleartimeout.out
Normal file
23
cli/tests/test_finally_cleartimeout.out
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
Check [WILDCARD]/$deno$test.ts
|
||||||
|
running 2 tests
|
||||||
|
test error ... FAILED ([WILDCARD])
|
||||||
|
test success ... ok ([WILDCARD])
|
||||||
|
|
||||||
|
failures:
|
||||||
|
|
||||||
|
error
|
||||||
|
Error: fail
|
||||||
|
at [WILDCARD]/test_finally_cleartimeout.ts:4:11
|
||||||
|
at asyncOpSanitizer (deno:runtime/js/40_testing.js:38:15)
|
||||||
|
at Object.resourceSanitizer [as fn] (deno:runtime/js/40_testing.js:74:13)
|
||||||
|
at TestRunner.[Symbol.asyncIterator] (deno:runtime/js/40_testing.js:249:24)
|
||||||
|
at AsyncGenerator.next (<anonymous>)
|
||||||
|
at Object.runTests (deno:runtime/js/40_testing.js:326:22)
|
||||||
|
at async [WILDCARD]/$deno$test.ts:3:1
|
||||||
|
|
||||||
|
failures:
|
||||||
|
|
||||||
|
error
|
||||||
|
|
||||||
|
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
|
||||||
|
|
11
cli/tests/test_finally_cleartimeout.ts
Normal file
11
cli/tests/test_finally_cleartimeout.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Deno.test("error", function () {
|
||||||
|
const timer = setTimeout(() => null, 10000);
|
||||||
|
try {
|
||||||
|
throw new Error("fail");
|
||||||
|
} finally {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("success", function () {
|
||||||
|
});
|
|
@ -34,11 +34,14 @@
|
||||||
function assertOps(fn) {
|
function assertOps(fn) {
|
||||||
return async function asyncOpSanitizer() {
|
return async function asyncOpSanitizer() {
|
||||||
const pre = metrics();
|
const pre = metrics();
|
||||||
|
try {
|
||||||
await fn();
|
await fn();
|
||||||
|
} finally {
|
||||||
// Defer until next event loop turn - that way timeouts and intervals
|
// Defer until next event loop turn - that way timeouts and intervals
|
||||||
// cleared can actually be removed from resource table, otherwise
|
// cleared can actually be removed from resource table, otherwise
|
||||||
// false positives may occur (https://github.com/denoland/deno/issues/4591)
|
// false positives may occur (https://github.com/denoland/deno/issues/4591)
|
||||||
await delay(0);
|
await delay(0);
|
||||||
|
}
|
||||||
const post = metrics();
|
const post = metrics();
|
||||||
// We're checking diff because one might spawn HTTP server in the background
|
// We're checking diff because one might spawn HTTP server in the background
|
||||||
// that will be a pending async op before test starts.
|
// that will be a pending async op before test starts.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue