Skip to content

Commit

Permalink
test: fs.watch filename check for Windows & AIX
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Young committed May 22, 2017
1 parent 9bd4012 commit 64884c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2406,7 +2406,7 @@ this improves the usability of file watching. This is expected behavior.
<!--type=misc-->

Providing `filename` argument in the callback is only supported on Linux,
macOS, and Windows. Even on supported platforms, `filename` is not always
macOS, Windows, and AIX. Even on supported platforms, `filename` is not always
guaranteed to be provided. Therefore, don't assume that `filename` argument is
always provided in the callback, and have some fallback logic if it is null.

Expand Down
14 changes: 5 additions & 9 deletions test/parallel/test-fs-watchfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,20 @@ fs.watchFile(enoentFile, {interval: 0}, common.mustCall(function(curr, prev) {
}
}, 2));

// Watch events should callback with a filename
if (common.isLinux || common.isOSX) {
// Watch events should callback with a filename on supported systems
if (common.isLinux || common.isOSX || common.isWindows || common.isAix) {
const dir = common.tmpDir + '/watch';

fs.mkdir(dir, common.mustCall(function(err) {
assert(!err);
if (err) assert.fail(err);

fs.watch(dir, common.mustCall(function(eventType, filename) {
this._handle.close();
common.refreshTmpDir();
assert.strictEqual(filename, 'foo.txt');
}));

fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall((err) => {
if (err) {
common.refreshTmpDir();
assert(!err);
}
fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall(function(err) {
if (err) assert.fail(err);
}));
}));
}

0 comments on commit 64884c2

Please sign in to comment.