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: https://github.com/nodejs/node/issues/8045 PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
66d697cb5c
commit
5f617c5f9e
@ -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});
|
||||
|
||||
|
@ -21,11 +21,6 @@ var filenameTwo = 'hasOwnProperty';
|
||||
var filepathTwo = filenameTwo;
|
||||
var filepathTwoAbs = path.join(testDir, filenameTwo);
|
||||
|
||||
var filenameThree = 'newfile.txt';
|
||||
var testsubdir = path.join(testDir, 'testsubdir');
|
||||
var filepathThree = path.join(testsubdir, filenameThree);
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.ok(watchSeenOne > 0);
|
||||
assert.ok(watchSeenTwo > 0);
|
||||
@ -78,7 +73,9 @@ setImmediate(function() {
|
||||
fs.writeFileSync(filepathTwoAbs, 'pardner');
|
||||
});
|
||||
|
||||
fs.mkdirSync(testsubdir, 0o700);
|
||||
const filenameThree = 'newfile.txt';
|
||||
const testsubdir = fs.mkdtempSync(testDir + path.sep);
|
||||
const filepathThree = path.join(testsubdir, filenameThree);
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user