forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test): Improve reliability of
deno test
's op sanitizer with tim…
…ers (denoland#12908) Although not easy to replicate in the wild, the `deno test` op sanitizer can fail when there are intervals that started before a test runs, since the op sanitizer can end up running in the time between the timer op for an interval's run resolves and the op for the next run starts. This change fixes that by adding a new macrotask callback that will run after the timer macrotask queue has drained. This ensures that there is a timer op if there are any timers which are unresolved by the time the op sanitizer runs.
- Loading branch information
1 parent
44ccae1
commit f4a9303
Showing
4 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Check [WILDCARD]/testdata/test/ops_sanitizer_timeout_failure.ts | ||
running 1 test from [WILDCARD]/testdata/test/ops_sanitizer_timeout_failure.ts | ||
test wait ... ok ([WILDCARD]) | ||
|
||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
let intervalHandle: number; | ||
let firstIntervalPromise: Promise<void>; | ||
|
||
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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters