From ae5d5658b91cdac4fe55b9e5e8c8e275449b4635 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 11 Jul 2018 20:04:28 -0700 Subject: [PATCH] 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 Reviewed-By: Ruben Bridgewater --- .../test-fs-watch-file-enoent-after-deletion.js | 3 --- 1 file changed, 3 deletions(-) rename test/{sequential => parallel}/test-fs-watch-file-enoent-after-deletion.js (94%) diff --git a/test/sequential/test-fs-watch-file-enoent-after-deletion.js b/test/parallel/test-fs-watch-file-enoent-after-deletion.js similarity index 94% rename from test/sequential/test-fs-watch-file-enoent-after-deletion.js rename to test/parallel/test-fs-watch-file-enoent-after-deletion.js index f5b9012acabe58..83c7516c9c6ca9 100644 --- a/test/sequential/test-fs-watch-file-enoent-after-deletion.js +++ b/test/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); }));