Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Jun 18, 2019
1 parent 2a9f1ad commit ea63557
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit ea63557

Please sign in to comment.