Skip to content

Commit e6f5abb

Browse files
committed
test: make fs watch test more stable
1 parent ccb8aae commit e6f5abb

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

test/pummel/test-fs-watch-non-recursive.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if (common.isIBMi) {
2828

2929
const path = require('path');
3030
const fs = require('fs');
31-
31+
const assert = require('assert');
3232
const tmpdir = require('../common/tmpdir');
3333
tmpdir.refresh();
3434

@@ -38,13 +38,12 @@ const filepath = path.join(testsubdir, 'watch.txt');
3838

3939
fs.mkdirSync(testsubdir, 0o700);
4040

41-
// Need a grace period, else the mkdirSync() above fires off an event.
41+
const watcher = fs.watch(testDir, { persistent: true }, (event, filename) => {
42+
assert.equal(filename, 'testsubdir');
43+
});
44+
setTimeout(function() {
45+
fs.writeFileSync(filepath, 'test');
46+
}, 100);
4247
setTimeout(function() {
43-
const watcher = fs.watch(testDir, { persistent: true }, common.mustNotCall());
44-
setTimeout(function() {
45-
fs.writeFileSync(filepath, 'test');
46-
}, 100);
47-
setTimeout(function() {
48-
watcher.close();
49-
}, 500);
50-
}, 50);
48+
watcher.close();
49+
}, 500);

0 commit comments

Comments
 (0)