Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix flaky fs-watch tests #8115

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 3 additions & 6 deletions test/sequential/test-fs-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -78,7 +73,9 @@ setImmediate(function() {
fs.writeFileSync(filepathTwoAbs, 'pardner');
});

fs.mkdirSync(testsubdir, 0o700);
var filenameThree = 'newfile.txt';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make these const?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I was just trying to keep the modifications to a minimum. Should I use const everywhere on the test or just in the variables I moved?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just update the variables you're moving. It won't change the size of the diff.

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

assert.doesNotThrow(
function() {
Expand Down