Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4f09886

Browse filesBrowse files
santigimenoevanlucas
authored andcommitted
test: fix flaky fs-watch tests
`test-fs-watch-recursive` and `test-fs-watch` were both watching the same folder: `tmp/testsubdir` so running them sequentially on `OS X` could make `test-fs-watch` to fail due to events generated in the other test. Make them watch a random directory to fix the issue. Fixes: #8045 PR-URL: #8115 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 82329b6 commit 4f09886
Copy full SHA for 4f09886

File tree

Expand file treeCollapse file tree

2 files changed

+6
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-11
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-fs-watch-recursive.js
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ const fs = require('fs');
1313

1414
const testDir = common.tmpDir;
1515
const filenameOne = 'watch.txt';
16-
const testsubdirName = 'testsubdir';
17-
const testsubdir = path.join(testDir, testsubdirName);
18-
const relativePathOne = path.join('testsubdir', filenameOne);
19-
const filepathOne = path.join(testsubdir, filenameOne);
2016

2117
common.refreshTmpDir();
2218

23-
fs.mkdirSync(testsubdir, 0o700);
19+
const testsubdir = fs.mkdtempSync(testDir + path.sep);
20+
const relativePathOne = path.join(path.basename(testsubdir), filenameOne);
21+
const filepathOne = path.join(testsubdir, filenameOne);
2422

2523
const watcher = fs.watch(testDir, {recursive: true});
2624

Collapse file

‎test/sequential/test-fs-watch.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-fs-watch.js
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ var filenameTwo = 'hasOwnProperty';
2121
var filepathTwo = filenameTwo;
2222
var filepathTwoAbs = path.join(testDir, filenameTwo);
2323

24-
var filenameThree = 'newfile.txt';
25-
var testsubdir = path.join(testDir, 'testsubdir');
26-
var filepathThree = path.join(testsubdir, filenameThree);
27-
28-
2924
process.on('exit', function() {
3025
assert.ok(watchSeenOne > 0);
3126
assert.ok(watchSeenTwo > 0);
@@ -78,7 +73,9 @@ setImmediate(function() {
7873
fs.writeFileSync(filepathTwoAbs, 'pardner');
7974
});
8075

81-
fs.mkdirSync(testsubdir, 0o700);
76+
const filenameThree = 'newfile.txt';
77+
const testsubdir = fs.mkdtempSync(testDir + path.sep);
78+
const filepathThree = path.join(testsubdir, filenameThree);
8279

8380
assert.doesNotThrow(
8481
function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.