Skip to content

Commit

Permalink
test: make fs watch test more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamingr committed Jan 27, 2022
1 parent ccb8aae commit e6f5abb
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/pummel/test-fs-watch-non-recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (common.isIBMi) {

const path = require('path');
const fs = require('fs');

const assert = require('assert');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

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

fs.mkdirSync(testsubdir, 0o700);

// Need a grace period, else the mkdirSync() above fires off an event.
const watcher = fs.watch(testDir, { persistent: true }, (event, filename) => {
assert.equal(filename, 'testsubdir');
});
setTimeout(function() {
fs.writeFileSync(filepath, 'test');
}, 100);
setTimeout(function() {
const watcher = fs.watch(testDir, { persistent: true }, common.mustNotCall());
setTimeout(function() {
fs.writeFileSync(filepath, 'test');
}, 100);
setTimeout(function() {
watcher.close();
}, 500);
}, 50);
watcher.close();
}, 500);

0 comments on commit e6f5abb

Please sign in to comment.