Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: test: fix flaky test-statwatcher.js #28273

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions test/async-hooks/test-statwatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,25 @@ assert.strictEqual(as.length, 2);
const statwatcher2 = as[1];
assert.strictEqual(statwatcher2.type, 'STATWATCHER');
assert.strictEqual(typeof statwatcher2.uid, 'number');
assert.notStrictEqual(statwatcher2.uid, statwatcher1.uid);
assert.strictEqual(statwatcher2.triggerAsyncId, 1);
checkInvocations(statwatcher1, { init: 1 },
'watcher1: when started to watch second file');
checkInvocations(statwatcher2, { init: 1 },
'watcher2: when started to watch second file');

setTimeout(() => fs.writeFileSync(file1, 'foo++'),
common.platformTimeout(100));
const interval1 = setInterval(() => fs.writeFileSync(file1, 'foo++'), 100);
w1.once('change', common.mustCall(() => {
clearInterval(interval1);
setImmediate(() => {
checkInvocations(statwatcher1, { init: 1, before: 1, after: 1 },
'watcher1: when unwatched first file');
checkInvocations(statwatcher2, { init: 1 },
'watcher2: when unwatched first file');

setTimeout(() => fs.writeFileSync(file2, 'bar++'),
common.platformTimeout(100));
const interval2 = setInterval(() => fs.writeFileSync(file2, 'bar++'), 100);
w2.once('change', common.mustCall(() => {
clearInterval(interval2);
setImmediate(() => {
checkInvocations(statwatcher1, { init: 1, before: 1, after: 1 },
'watcher1: when unwatched second file');
Expand Down