Skip to content

Commit

Permalink
test: replace flaky immediates event loop test
Browse files Browse the repository at this point in the history
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
apapirovski committed Jan 7, 2022
1 parent 79b21ee commit 8f73f2b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 59 deletions.
2 changes: 0 additions & 2 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ prefix parallel
test-repl-sigint-nested-eval: PASS, FLAKY

[$system==win32]
# https://github.com/nodejs/node/issues/24497
test-timers-immediate-queue: PASS,FLAKY
# https://github.com/nodejs/node/issues/23277
test-worker-memory: PASS,FLAKY
# https://github.com/nodejs/node/issues/41206
Expand Down
34 changes: 34 additions & 0 deletions test/parallel/test-timers-immediate-event-loop.js
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();
}));
57 changes: 0 additions & 57 deletions test/parallel/test-timers-immediate-queue.js

This file was deleted.

0 comments on commit 8f73f2b

Please sign in to comment.