Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: ensure delay in recursive fs watch tests #51842

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ watcher.on('change', function(event, filename) {
}
});

fs.writeFileSync(childrenAbsolutePath, 'world');
// Do the write with a delay to ensure that the OS is ready to notify us.
setTimeout(() => {
fs.writeFileSync(childrenAbsolutePath, 'world');
}, common.platformTimeout(200));

process.once('exit', function() {
assert(watcherClosed, 'watcher Object was not closed');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ watcher.on('change', function(event, filename) {
}
});

fs.mkdirSync(filePath);
fs.writeFileSync(childrenAbsolutePath, 'world');
// Do the write with a delay to ensure that the OS is ready to notify us.
setTimeout(() => {
fs.mkdirSync(filePath);
fs.writeFileSync(childrenAbsolutePath, 'world');
}, common.platformTimeout(200));

process.once('exit', function() {
assert(watcherClosed, 'watcher Object was not closed');
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-fs-watch-recursive-add-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ watcher.on('change', function(event, filename) {
}
});

fs.writeFileSync(testFile, 'world');
// Do the write with a delay to ensure that the OS is ready to notify us.
setTimeout(() => {
fs.writeFileSync(testFile, 'world');
}, common.platformTimeout(200));

process.once('exit', function() {
assert(watcherClosed, 'watcher Object was not closed');
Expand Down
7 changes: 6 additions & 1 deletion test/parallel/test-fs-watch-recursive-assert-leaks.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ watcher.on('change', common.mustCallAtLeast(async (event, filename) => {
process.on('exit', function() {
assert(watcherClosed, 'watcher Object was not closed');
});
fs.writeFileSync(filePath, 'content');

// Do the write with a delay to ensure that the OS is ready to notify us.
(async () => {
await setTimeout(200);
fs.writeFileSync(filePath, 'content');
})().then(common.mustCall());
5 changes: 4 additions & 1 deletion test/parallel/test-fs-watch-recursive-sync-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ const watcher = watch(tmpDir, { recursive: true }, common.mustCall((eventType, _
assert.strictEqual(join(tmpDir, _filename), filename);
}));

writeFileSync(filename, 'foobar2');
// Do the write with a delay to ensure that the OS is ready to notify us.
setTimeout(() => {
writeFileSync(filename, 'foobar2');
});
joyeecheung marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 4 additions & 1 deletion test/parallel/test-fs-watch-recursive-update-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ watcher.on('change', common.mustCallAtLeast(function(event, filename) {
}
}));

fs.writeFileSync(testFile, 'hello');
// Do the write with a delay to ensure that the OS is ready to notify us.
setTimeout(() => {
fs.writeFileSync(testFile, 'hello');
}, common.platformTimeout(200));
Loading