Skip to content

Commit 9f312fb

Browse files
committed
fixup! test: split test-fs-watch-ignore-*
1 parent 1e4653b commit 9f312fb

13 files changed

Lines changed: 187 additions & 121 deletions

test/parallel/parallel.status

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,32 @@ test-domain-throw-error-then-throw-from-uncaught-exception-handler: PASS, FLAKY
7676
test-domain-with-abort-on-uncaught-exception: PASS, FLAKY
7777
# https://github.com/nodejs/node/issues/54346
7878
test-esm-loader-hooks-inspect-wait: PASS, FLAKY
79+
# https://github.com/nodejs/node/issues/61520
7980
test-fs-promises-watch-iterator: SKIP
81+
test-fs-promises-watch-ignore-function: SKIP
82+
test-fs-promises-watch-ignore-glob: SKIP
83+
test-fs-promises-watch-ignore-mixed: SKIP
84+
test-fs-promises-watch-ignore-regexp: SKIP
85+
test-fs-watch-ignore-function: SKIP
86+
test-fs-watch-ignore-glob: SKIP
87+
test-fs-watch-ignore-mixed: SKIP
88+
test-fs-watch-ignore-regexp: SKIP
8089
# https://github.com/nodejs/node/issues/50050
8190
test-tick-processor-arguments: SKIP
8291

8392
[$system==freebsd]
8493
# https://github.com/nodejs/node/issues/54346
8594
test-esm-loader-hooks-inspect-wait: PASS, FLAKY
95+
# https://github.com/nodejs/node/issues/61520
8696
test-fs-promises-watch-iterator: SKIP
97+
test-fs-promises-watch-ignore-function: SKIP
98+
test-fs-promises-watch-ignore-glob: SKIP
99+
test-fs-promises-watch-ignore-mixed: SKIP
100+
test-fs-promises-watch-ignore-regexp: SKIP
101+
test-fs-watch-ignore-function: SKIP
102+
test-fs-watch-ignore-glob: SKIP
103+
test-fs-watch-ignore-mixed: SKIP
104+
test-fs-watch-ignore-regexp: SKIP
87105

88106
[$system==aix]
89107
# https://github.com/nodejs/node/issues/54346

test/parallel/test-fs-promises-watch-ignore-function.mjs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { skipIfNoWatch } from '../common/watch.js';
33

44
skipIfNoWatch();
55

6-
// if (common.isSunOS)
7-
// common.skip('`fs.watch()` is not reliable on SunOS.');
8-
96
const assert = await import('node:assert');
107
const path = await import('node:path');
118
const tmpdir = await import('../common/tmpdir.js');
9+
const { setTimeout } = await import('node:timers/promises');
1210
const { watch } = await import('node:fs/promises');
1311
const { writeFileSync } = await import('node:fs');
1412

@@ -20,21 +18,29 @@ const ignoreFile = '.hidden';
2018
const keepFilePath = path.join(testDir, keepFile);
2119
const ignoreFilePath = path.join(testDir, ignoreFile);
2220

23-
const watcher = watch(testDir, {
24-
ignore: (filename) => filename.startsWith('.'),
25-
});
21+
async function watchDir() {
22+
const watcher = watch(testDir, {
23+
ignore: (filename) => filename.startsWith('.'),
24+
});
2625

27-
// Do the write with a delay to ensure that the OS is ready to notify us. See
28-
// https://github.com/nodejs/node/issues/52601.
29-
setTimeout(() => {
30-
writeFileSync(ignoreFilePath, 'ignored');
31-
writeFileSync(keepFilePath, 'content');
32-
}, common.platformTimeout(100));
26+
for await (const { filename } of watcher) {
27+
assert.notStrictEqual(filename, ignoreFile);
3328

34-
for await (const { filename } of watcher) {
35-
assert.notStrictEqual(filename, ignoreFile);
29+
if (filename === keepFile) {
30+
break;
31+
}
32+
}
33+
}
3634

37-
if (filename === keepFile) {
38-
break;
35+
async function writeFiles() {
36+
if (common.isMacOS) {
37+
// Do the write with a delay to ensure that the OS is ready to notify us.
38+
// See https://github.com/nodejs/node/issues/52601.
39+
await setTimeout(common.platformTimeout(100));
3940
}
41+
42+
writeFileSync(ignoreFilePath, 'ignored');
43+
writeFileSync(keepFilePath, 'content');
4044
}
45+
46+
await Promise.all([watchDir(), writeFiles()]);

test/parallel/test-fs-promises-watch-ignore-glob.mjs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { skipIfNoWatch } from '../common/watch.js';
33

44
skipIfNoWatch();
55

6-
// if (common.isSunOS)
7-
// common.skip('`fs.watch()` is not reliable on SunOS.');
8-
96
const assert = await import('node:assert');
107
const path = await import('node:path');
118
const tmpdir = await import('../common/tmpdir.js');
9+
const { setTimeout } = await import('node:timers/promises');
1210
const { watch } = await import('node:fs/promises');
1311
const { writeFileSync } = await import('node:fs');
1412

@@ -20,19 +18,27 @@ const ignoreFile = 'ignore.log';
2018
const keepFilePath = path.join(testDir, keepFile);
2119
const ignoreFilePath = path.join(testDir, ignoreFile);
2220

23-
const watcher = watch(testDir, { ignore: '*.log' });
21+
async function watchDir() {
22+
const watcher = watch(testDir, { ignore: '*.log' });
2423

25-
// Do the write with a delay to ensure that the OS is ready to notify us. See
26-
// https://github.com/nodejs/node/issues/52601.
27-
setTimeout(() => {
28-
writeFileSync(ignoreFilePath, 'ignored');
29-
writeFileSync(keepFilePath, 'content');
30-
}, common.platformTimeout(100));
24+
for await (const { filename } of watcher) {
25+
assert.notStrictEqual(filename, ignoreFile);
3126

32-
for await (const { filename } of watcher) {
33-
assert.notStrictEqual(filename, ignoreFile);
27+
if (filename === keepFile) {
28+
break;
29+
}
30+
}
31+
}
3432

35-
if (filename === keepFile) {
36-
break;
33+
async function writeFiles() {
34+
if (common.isMacOS) {
35+
// Do the write with a delay to ensure that the OS is ready to notify us.
36+
// See https://github.com/nodejs/node/issues/52601.
37+
await setTimeout(common.platformTimeout(100));
3738
}
39+
40+
writeFileSync(ignoreFilePath, 'ignored');
41+
writeFileSync(keepFilePath, 'content');
3842
}
43+
44+
await Promise.all([watchDir(), writeFiles()]);

test/parallel/test-fs-promises-watch-ignore-mixed.mjs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { skipIfNoWatch } from '../common/watch.js';
33

44
skipIfNoWatch();
55

6-
// if (common.isSunOS)
7-
// common.skip('`fs.watch()` is not reliable on SunOS.');
8-
96
const assert = await import('node:assert');
107
const path = await import('node:path');
118
const tmpdir = await import('../common/tmpdir.js');
9+
const { setTimeout } = await import('node:timers/promises');
1210
const { watch } = await import('node:fs/promises');
1311
const { writeFileSync } = await import('node:fs');
1412

@@ -22,26 +20,34 @@ const keepFilePath = path.join(testDir, keepFile);
2220
const ignoreLogPath = path.join(testDir, ignoreLog);
2321
const ignoreTmpPath = path.join(testDir, ignoreTmp);
2422

25-
const watcher = watch(testDir, {
26-
ignore: [
27-
'*.log',
28-
/\.tmp$/,
29-
],
30-
});
23+
async function watchDir() {
24+
const watcher = watch(testDir, {
25+
ignore: [
26+
'*.log',
27+
/\.tmp$/,
28+
],
29+
});
30+
31+
for await (const { filename } of watcher) {
32+
assert.notStrictEqual(filename, ignoreLog);
33+
assert.notStrictEqual(filename, ignoreTmp);
34+
35+
if (filename === keepFile) {
36+
break;
37+
}
38+
}
39+
}
40+
41+
async function writeFiles() {
42+
if (common.isMacOS) {
43+
// Do the write with a delay to ensure that the OS is ready to notify us.
44+
// See https://github.com/nodejs/node/issues/52601.
45+
await setTimeout(common.platformTimeout(100));
46+
}
3147

32-
// Do the write with a delay to ensure that the OS is ready to notify us. See
33-
// https://github.com/nodejs/node/issues/52601.
34-
setTimeout(() => {
3548
writeFileSync(ignoreLogPath, 'ignored');
3649
writeFileSync(ignoreTmpPath, 'ignored');
3750
writeFileSync(keepFilePath, 'content');
38-
}, common.platformTimeout(100));
39-
40-
for await (const { filename } of watcher) {
41-
assert.notStrictEqual(filename, ignoreLog);
42-
assert.notStrictEqual(filename, ignoreTmp);
43-
44-
if (filename === keepFile) {
45-
break;
46-
}
4751
}
52+
53+
await Promise.all([watchDir(), writeFiles()]);

test/parallel/test-fs-promises-watch-ignore-regexp.mjs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { skipIfNoWatch } from '../common/watch.js';
33

44
skipIfNoWatch();
55

6-
// if (common.isSunOS)
7-
// common.skip('`fs.watch()` is not reliable on SunOS.');
8-
96
const assert = await import('node:assert');
107
const path = await import('node:path');
118
const tmpdir = await import('../common/tmpdir.js');
9+
const { setTimeout } = await import('node:timers/promises');
1210
const { watch } = await import('node:fs/promises');
1311
const { writeFileSync } = await import('node:fs');
1412

@@ -20,19 +18,27 @@ const ignoreFile = 'ignore.tmp';
2018
const keepFilePath = path.join(testDir, keepFile);
2119
const ignoreFilePath = path.join(testDir, ignoreFile);
2220

23-
const watcher = watch(testDir, { ignore: /\.tmp$/ });
21+
async function watchDir() {
22+
const watcher = watch(testDir, { ignore: /\.tmp$/ });
2423

25-
// Do the write with a delay to ensure that the OS is ready to notify us. See
26-
// https://github.com/nodejs/node/issues/52601.
27-
setTimeout(() => {
28-
writeFileSync(ignoreFilePath, 'ignored');
29-
writeFileSync(keepFilePath, 'content');
30-
}, common.platformTimeout(100));
24+
for await (const { filename } of watcher) {
25+
assert.notStrictEqual(filename, ignoreFile);
3126

32-
for await (const { filename } of watcher) {
33-
assert.notStrictEqual(filename, ignoreFile);
27+
if (filename === keepFile) {
28+
break;
29+
}
30+
}
31+
}
3432

35-
if (filename === keepFile) {
36-
break;
33+
async function writeFiles() {
34+
if (common.isMacOS) {
35+
// Do the write with a delay to ensure that the OS is ready to notify us.
36+
// See https://github.com/nodejs/node/issues/52601.
37+
await setTimeout(common.platformTimeout(100));
3738
}
39+
40+
writeFileSync(ignoreFilePath, 'ignored');
41+
writeFileSync(keepFilePath, 'content');
3842
}
43+
44+
await Promise.all([watchDir(), writeFiles()]);

test/parallel/test-fs-watch-ignore-function.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ const { skipIfNoWatch } = require('../common/watch.js');
55

66
skipIfNoWatch();
77

8-
// if (common.isSunOS)
9-
// common.skip('`fs.watch()` is not reliable on SunOS.');
10-
118
const assert = require('assert');
129
const path = require('path');
1310
const fs = require('fs');
@@ -33,9 +30,15 @@ watcher.on('change', common.mustCallAtLeast((event, filename) => {
3330
}
3431
}, 1));
3532

36-
// Do the write with a delay to ensure that the OS is ready to notify us. See
37-
// https://github.com/nodejs/node/issues/52601.
38-
setTimeout(() => {
33+
function writeFiles() {
3934
fs.writeFileSync(ignoredFilePath, 'ignored');
4035
fs.writeFileSync(testFilePath, 'content');
41-
}, common.platformTimeout(100));
36+
}
37+
38+
if (common.isMacOS) {
39+
// Do the write with a delay to ensure that the OS is ready to notify us. See
40+
// https://github.com/nodejs/node/issues/52601.
41+
setTimeout(writeFiles, common.platformTimeout(100));
42+
} else {
43+
writeFiles();
44+
}

test/parallel/test-fs-watch-ignore-glob.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ const { skipIfNoWatch } = require('../common/watch.js');
55

66
skipIfNoWatch();
77

8-
// if (common.isSunOS)
9-
// common.skip('`fs.watch()` is not reliable on SunOS.');
10-
118
const assert = require('assert');
129
const path = require('path');
1310
const fs = require('fs');
@@ -33,9 +30,15 @@ watcher.on('change', common.mustCallAtLeast((event, filename) => {
3330
}
3431
}, 1));
3532

36-
// Do the write with a delay to ensure that the OS is ready to notify us. See
37-
// https://github.com/nodejs/node/issues/52601.
38-
setTimeout(() => {
33+
function writeFiles() {
3934
fs.writeFileSync(ignoredFilePath, 'ignored');
4035
fs.writeFileSync(testFilePath, 'content');
41-
}, common.platformTimeout(100));
36+
}
37+
38+
if (common.isMacOS) {
39+
// Do the write with a delay to ensure that the OS is ready to notify us. See
40+
// https://github.com/nodejs/node/issues/52601.
41+
setTimeout(writeFiles, common.platformTimeout(100));
42+
} else {
43+
writeFiles();
44+
}

test/parallel/test-fs-watch-ignore-mixed.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ const { skipIfNoWatch } = require('../common/watch.js');
55

66
skipIfNoWatch();
77

8-
// if (common.isSunOS)
9-
// common.skip('`fs.watch()` is not reliable on SunOS.');
10-
118
const assert = require('assert');
129
const path = require('path');
1310
const fs = require('fs');
@@ -43,11 +40,17 @@ watcher.on('change', common.mustCallAtLeast((event, filename) => {
4340
}
4441
}, 1));
4542

46-
// Do the write with a delay to ensure that the OS is ready to notify us. See
47-
// https://github.com/nodejs/node/issues/52601.
48-
setTimeout(() => {
43+
function writeFiles() {
4944
fs.writeFileSync(ignoredLogPath, 'ignored');
5045
fs.writeFileSync(ignoredTmpPath, 'ignored');
5146
fs.writeFileSync(ignoredHiddenPath, 'ignored');
5247
fs.writeFileSync(testFilePath, 'content');
53-
}, common.platformTimeout(100));
48+
}
49+
50+
if (common.isMacOS) {
51+
// Do the write with a delay to ensure that the OS is ready to notify us. See
52+
// https://github.com/nodejs/node/issues/52601.
53+
setTimeout(writeFiles, common.platformTimeout(100));
54+
} else {
55+
writeFiles();
56+
}

test/parallel/test-fs-watch-ignore-recursive-glob-subdirectories.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ const { skipIfNoWatch } = require('../common/watch.js');
55

66
skipIfNoWatch();
77

8-
// if (common.isSunOS)
9-
// common.skip('`fs.watch()` is not reliable on SunOS.');
10-
118
const assert = require('assert');
129
const path = require('path');
1310
const fs = require('fs');
@@ -45,9 +42,15 @@ watcher.on('change', common.mustCallAtLeast((event, filename) => {
4542
}
4643
}, 1));
4744

48-
// Do the write with a delay to ensure that the OS is ready to notify us. See
49-
// https://github.com/nodejs/node/issues/52601.
50-
setTimeout(() => {
45+
function writeFiles() {
5146
fs.writeFileSync(ignoredFilePath, '{}');
5247
fs.writeFileSync(testFilePath, 'console.log("hello-' + Date.now() + '")');
53-
}, common.platformTimeout(100));
48+
}
49+
50+
if (common.isMacOS) {
51+
// Do the write with a delay to ensure that the OS is ready to notify us. See
52+
// https://github.com/nodejs/node/issues/52601.
53+
setTimeout(writeFiles, common.platformTimeout(100));
54+
} else {
55+
writeFiles();
56+
}

0 commit comments

Comments
 (0)