★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/ae5d5658b9Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files

test: fix flaky watchFile()

The regression that test-fs-watch-file-enoent-after-deletion was written
to test for involves whether or not the callback runs or not. Checking
what the file watcher reports unfortunately is subject to race
conditions on Windows (and possibly elsewhere) because the file watcher
returns control to the event loop before it may be receiving data from
the OS. So remove those assertions. The test still checks what it is
supposed to check, but is no longer subject to race conditions.

Fixes: #21692

PR-URL: #21694
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information...
Trott authored and targos committed Jul 12, 2018
1 parent b229129 commit ae5d5658b91cdac4fe55b9e5e8c8e275449b4635
Showing with 0 additions and 3 deletions.
  1. +0 −3 test/{sequential → parallel}/test-fs-watch-file-enoent-after-deletion.js
@@ -32,7 +32,6 @@ const common = require('../common');
// stopped it from getting emitted.
// https://github.com/nodejs/node-v0.x-archive/issues/4027

const assert = require('assert');
const path = require('path');
const fs = require('fs');

@@ -43,8 +42,6 @@ const filename = path.join(tmpdir.path, 'watched');
fs.writeFileSync(filename, 'quis custodiet ipsos custodes');

fs.watchFile(filename, { interval: 50 }, common.mustCall(function(curr, prev) {
assert.strictEqual(prev.nlink, 1);
assert.strictEqual(curr.nlink, 0);
fs.unwatchFile(filename);
}));

0 comments on commit ae5d565

Please sign in to comment.
You can’t perform that action at this time.