GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: ignore unrelated events in FW watch tests · nodejs/node@10b68ed

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-fs-watch-recursive-add-file-to-existing-subfolder.js
    • test-fs-watch-recursive-add-file-to-new-folder.js
    • test-fs-watch-recursive-add-file-with-url.js
    • test-fs-watch-recursive-add-file.js
    • test-fs-watch-recursive-add-folder.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-fs-watch-recursive-add-file-to-existing-subfolder.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watch-recursive-add-file-to-existing-subfolder.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ const relativePath = path.join(file, path.basename(subfolderPath), childrenFile)
4040
const watcher = fs.watch(testDirectory, { recursive: true });
4141
let watcherClosed = false;
4242
watcher.on('change', function(event, filename) {
43-
assert.strictEqual(event, 'rename');
44-
4543
if (filename === relativePath) {
44+
assert.strictEqual(event, 'rename');
4645
watcher.close();
4746
watcherClosed = true;
4847
}
Collapse file

‎test/parallel/test-fs-watch-recursive-add-file-to-new-folder.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watch-recursive-add-file-to-new-folder.js
+12-24Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,20 @@ const childrenAbsolutePath = path.join(filePath, childrenFile);
3333
const childrenRelativePath = path.join(path.basename(filePath), childrenFile);
3434
let watcherClosed = false;
3535

36-
function doWatch() {
37-
const watcher = fs.watch(testDirectory, { recursive: true });
38-
watcher.on('change', function(event, filename) {
36+
const watcher = fs.watch(testDirectory, { recursive: true });
37+
watcher.on('change', function(event, filename) {
38+
if (filename === childrenRelativePath) {
3939
assert.strictEqual(event, 'rename');
40-
assert.ok(filename === path.basename(filePath) || filename === childrenRelativePath);
41-
42-
if (filename === childrenRelativePath) {
43-
watcher.close();
44-
watcherClosed = true;
45-
}
46-
});
47-
48-
// Do the write with a delay to ensure that the OS is ready to notify us.
49-
setTimeout(() => {
50-
fs.mkdirSync(filePath);
51-
fs.writeFileSync(childrenAbsolutePath, 'world');
52-
}, common.platformTimeout(200));
53-
}
40+
watcher.close();
41+
watcherClosed = true;
42+
}
43+
});
5444

55-
if (common.isMacOS) {
56-
// On macOS delay watcher start to avoid leaking previous events.
57-
// Refs: https://github.com/libuv/libuv/pull/4503
58-
setTimeout(doWatch, common.platformTimeout(100));
59-
} else {
60-
doWatch();
61-
}
45+
// Do the write with a delay to ensure that the OS is ready to notify us.
46+
setTimeout(() => {
47+
fs.mkdirSync(filePath);
48+
fs.writeFileSync(childrenAbsolutePath, 'world');
49+
}, common.platformTimeout(200));
6250

6351
process.once('exit', function() {
6452
assert(watcherClosed, 'watcher Object was not closed');
Collapse file

‎test/parallel/test-fs-watch-recursive-add-file-with-url.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watch-recursive-add-file-with-url.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ tmpdir.refresh();
3535
const watcher = fs.watch(url, { recursive: true });
3636
let watcherClosed = false;
3737
watcher.on('change', function(event, filename) {
38-
assert.strictEqual(event, 'rename');
39-
4038
if (filename === path.basename(filePath)) {
39+
assert.strictEqual(event, 'rename');
4140
watcher.close();
4241
watcherClosed = true;
4342
}
Collapse file

‎test/parallel/test-fs-watch-recursive-add-file.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watch-recursive-add-file.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ const testFile = path.join(testDirectory, 'file-1.txt');
3131
const watcher = fs.watch(testDirectory, { recursive: true });
3232
let watcherClosed = false;
3333
watcher.on('change', function(event, filename) {
34-
assert.strictEqual(event, 'rename');
35-
3634
if (filename === path.basename(testFile)) {
35+
assert.strictEqual(event, 'rename');
3736
watcher.close();
3837
watcherClosed = true;
3938
}
Collapse file

‎test/parallel/test-fs-watch-recursive-add-folder.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watch-recursive-add-folder.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ tmpdir.refresh();
3333
const watcher = fs.watch(testDirectory, { recursive: true });
3434
let watcherClosed = false;
3535
watcher.on('change', function(event, filename) {
36-
assert.strictEqual(event, 'rename');
37-
3836
if (filename === path.basename(testFile)) {
37+
assert.strictEqual(event, 'rename');
3938
watcher.close();
4039
watcherClosed = true;
4140
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.