test: fix fs-watch-recursive flakiness on OS X

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: https://github.com/nodejs/node/pull/4629
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Santiago Gimeno authored and Jeremiah Senkpiel committed 2016-09-09 11:06:16 -04:00
1 parent 372e4f3f79
commit c07e063dd9
1 file changed
+7 -1
+7 -1
View File
@@ -34,7 +34,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');