Browse Source

test,fs: delay unlink in test-regress-GH-4027.js

The sequential/test-regress-GH-4027 test is flaky with an increased
system load, failing when the watched file is unlinked before the
first state of the watched file is retrieved.

After increasing the delay before unlinking and calling setTimeout
after watchFile, the flakiness stopped reproducing.

PR-URL: https://github.com/nodejs/node/pull/14010
Fixes: https://github.com/nodejs/node/issues/13800
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
v6
Jaime Bernardo 8 years ago
committed by Rich Trott
parent
commit
f1c890afb0
  1. 3
      test/sequential/test-regress-GH-4027.js

3
test/sequential/test-regress-GH-4027.js

@ -29,10 +29,11 @@ common.refreshTmpDir();
const filename = path.join(common.tmpDir, 'watched');
fs.writeFileSync(filename, 'quis custodiet ipsos custodes');
setTimeout(fs.unlinkSync, 100, filename);
fs.watchFile(filename, { interval: 50 }, common.mustCall(function(curr, prev) {
assert.strictEqual(prev.nlink, 1);
assert.strictEqual(curr.nlink, 0);
fs.unwatchFile(filename);
}));
setTimeout(fs.unlinkSync, common.platformTimeout(300), filename);

Loading…
Cancel
Save