diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-03-14 20:11:55 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-03-19 07:40:47 +0800 |
commit | 897f7b6c6b5ce990329f30ed1f0784db183e8e5a (patch) | |
tree | 6da2781787e39d07b0d44103b31d1cad02516cd1 /test/sequential/test-fs-watch.js | |
parent | 301f6cc553bd73cfa345ae7de6ee81655efc57d0 (diff) | |
download | android-node-v8-897f7b6c6b5ce990329f30ed1f0784db183e8e5a.tar.gz android-node-v8-897f7b6c6b5ce990329f30ed1f0784db183e8e5a.tar.bz2 android-node-v8-897f7b6c6b5ce990329f30ed1f0784db183e8e5a.zip |
fs: improve errors in watchFile and unwatchFile
- Check if the watcher is active in JS land before
invoking the binding, act as a noop if the state of
the watcher does not match the expectation. This
avoids firing 'stop' when the watcher is already
stopped.
- Update comments, validate more arguments and
the type of the handle.
- Handle the errors from uv_fs_poll_start
- Create an `IsActive` helper method on StatWatcher
PR-URL: https://github.com/nodejs/node/pull/19345
Refs: https://github.com/nodejs/node/pull/19089
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/sequential/test-fs-watch.js')
-rw-r--r-- | test/sequential/test-fs-watch.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/test/sequential/test-fs-watch.js b/test/sequential/test-fs-watch.js index 91d750acd0..3c8ae0eba7 100644 --- a/test/sequential/test-fs-watch.js +++ b/test/sequential/test-fs-watch.js @@ -122,13 +122,20 @@ tmpdir.refresh(); code: 'ERR_ASSERTION' }); oldhandle.close(); // clean up +} - assert.throws(function() { - const w = fs.watchFile(__filename, { persistent: false }, +{ + let oldhandle; + assert.throws(() => { + const w = fs.watchFile(__filename, + { persistent: false }, common.mustNotCall()); oldhandle = w._handle; w._handle = { stop: w._handle.stop }; w.stop(); - }, /^TypeError: Illegal invocation$/); + }, { + message: 'handle must be a StatWatcher', + code: 'ERR_ASSERTION' + }); oldhandle.stop(); // clean up } |