forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: replace flaky immediates event loop test
Replace a flaky immediates event loop test that hasn't truly made sense for a while, since it has gone through so many different iterations, with a new test that is verifying the same behavior but without so much potential for flakiness. Fixes: nodejs#24497
- Loading branch information
1 parent
79b21ee
commit 8f73f2b
Showing
3 changed files
with
34 additions
and
59 deletions.
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,34 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const assert = require('assert'); | ||
const { sleep } = require('internal/util'); | ||
|
||
// SetImmediate should clear its existing queue on each event loop run | ||
// but leave any newly scheduled Immediates until the next run. | ||
// | ||
// Since timer expiries are notoriously flaky and dependant on specific | ||
// OS configurations, we instead just check that an Immediate queue | ||
// will eventually be interrupted by the timer — regardless of how long | ||
// it actually takes for that to happen. | ||
|
||
const duration = 1; | ||
let nextImmediate; | ||
|
||
const exit = common.mustCall(() => { | ||
assert.ok(nextImmediate.hasRef()); | ||
process.exit(); | ||
}); | ||
|
||
function check() { | ||
sleep(duration); | ||
nextImmediate = setImmediate(check); | ||
} | ||
|
||
setImmediate(common.mustCall(() => { | ||
setTimeout(exit, duration); | ||
|
||
check(); | ||
})); |
This file was deleted.
Oops, something went wrong.