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: https://github.com/nodejs/node/issues/21692

PR-URL: https://github.com/nodejs/node/pull/21694
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Rich Trott authored and Michaël Zasso committed 2018-07-14 12:03:01 +02:00
1 parent b2291296ef
commit ae5d5658b9
1 file changed
-3
@@ -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);
}));