Skip to content

Commit

Permalink
test: fix fs-watch-recursive flakiness on OS X
Browse files Browse the repository at this point in the history
The test is sometimes timing out because of a race condition between
the fs event generated on file creation and the event being registered
in the kqueue. To avoid this problem, create the file after 100 ms,
that is the value used in the `fs_event_watch_dir_recursive` libuv test.

PR-URL: #4629
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
santigimeno authored and Myles Borins committed Oct 10, 2016
1 parent ab08cc2 commit 6d3d58d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/parallel/test-fs-watch-recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ watcher.on('change', function(event, filename) {
watcherClosed = true;
});

fs.writeFileSync(filepathOne, 'world');
if (process.platform === 'darwin') {
setTimeout(function() {
fs.writeFileSync(filepathOne, 'world');
}, 100);
} else {
fs.writeFileSync(filepathOne, 'world');
}

process.on('exit', function() {
assert(watcherClosed, 'watcher Object was not closed');
Expand Down

0 comments on commit 6d3d58d

Please sign in to comment.