summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcharlierudolph <charles.rudolph@originate.com>2015-09-29 22:03:27 -0700
committercjihrig <cjihrig@gmail.com>2015-10-02 10:04:02 -0400
commit87e820ead58b65b7b92149be71549a238a28ece2 (patch)
tree2675ffa257dabbd5a891b77c1c434a9a58b3182f /test
parent02fe8215f09ce8a89a5cd4e76cbd78a59771c96e (diff)
downloadnode-new-87e820ead58b65b7b92149be71549a238a28ece2.tar.gz
fs: include filename in watch errors
This commit adds the relevant filename to fs.watch() errors. Refs: https://github.com/nodejs/node-v0.x-archive/pull/25542 PR-URL: https://github.com/nodejs/node/pull/2748 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/sequential/test-fs-watch.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/sequential/test-fs-watch.js b/test/sequential/test-fs-watch.js
index 10f4baf591..385cf47686 100644
--- a/test/sequential/test-fs-watch.js
+++ b/test/sequential/test-fs-watch.js
@@ -126,3 +126,20 @@ assert.throws(function() {
w.stop();
}, TypeError);
oldhandle.stop(); // clean up
+
+assert.throws(function() {
+ fs.watch('non-existent-file');
+}, function(err) {
+ assert(err);
+ assert(/non-existent-file/.test(err));
+ assert.equal(err.filename, 'non-existent-file');
+ return true;
+});
+
+var watcher = fs.watch(__filename);
+watcher.on('error', common.mustCall(function(err) {
+ assert(err);
+ assert(/non-existent-file/.test(err));
+ assert.equal(err.filename, 'non-existent-file');
+}));
+watcher._handle.onchange(-1, 'ENOENT', 'non-existent-file');