Skip to content

Commit

Permalink
test: fix flaky fs-watch tests
Browse files Browse the repository at this point in the history
`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: nodejs#8045
  • Loading branch information
santigimeno committed Aug 16, 2016
1 parent 3f6e1da commit 357e6c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions test/parallel/test-fs-watch-recursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ const fs = require('fs');

const testDir = common.tmpDir;
const filenameOne = 'watch.txt';
const testsubdirName = 'testsubdir';
const testsubdir = path.join(testDir, testsubdirName);
const relativePathOne = path.join('testsubdir', filenameOne);
const filepathOne = path.join(testsubdir, filenameOne);

common.refreshTmpDir();

fs.mkdirSync(testsubdir, 0o700);
const testsubdir = fs.mkdtempSync(testDir + path.sep);
const relativePathOne = path.join(path.basename(testsubdir), filenameOne);
const filepathOne = path.join(testsubdir, filenameOne);

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

Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-fs-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var filepathTwo = filenameTwo;
var filepathTwoAbs = path.join(testDir, filenameTwo);

var filenameThree = 'newfile.txt';
var testsubdir = path.join(testDir, 'testsubdir');
var testsubdir = fs.mkdtempSync(testDir + path.sep);
var filepathThree = path.join(testsubdir, filenameThree);


Expand Down

0 comments on commit 357e6c7

Please sign in to comment.