From 83e9a3ea59123d2d13f0884ba8c5f2c9f338f0d2 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 29 Feb 2020 16:19:17 -0800 Subject: [PATCH] test: add coverage for FSWatcher exception Cover an previously uncovered exception possible in the internal start function for FSWatcher. Signed-off-by: Rich Trott PR-URL: https://github.com/nodejs/node/pull/32057 Reviewed-By: Luigi Pinca Reviewed-By: Anto Aravinth --- test/sequential/test-fs-watch.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/sequential/test-fs-watch.js b/test/sequential/test-fs-watch.js index ff0a52c89c6790..8c543a2a17290a 100644 --- a/test/sequential/test-fs-watch.js +++ b/test/sequential/test-fs-watch.js @@ -125,9 +125,31 @@ tmpdir.refresh(); w.close(); }, { + name: 'Error', + code: 'ERR_INTERNAL_ASSERTION', message: /^handle must be a FSEvent/, + } + ); + oldhandle.close(); // clean up +} + +{ + let oldhandle; + assert.throws( + () => { + const w = fs.watch(__filename, common.mustNotCall()); + oldhandle = w._handle; + const protoSymbols = + Object.getOwnPropertySymbols(Object.getPrototypeOf(w)); + const kFSWatchStart = + protoSymbols.find((val) => val.toString() === 'Symbol(kFSWatchStart)'); + w._handle = {}; + w[kFSWatchStart](); + }, + { name: 'Error', code: 'ERR_INTERNAL_ASSERTION', + message: /^handle must be a FSEvent/, } ); oldhandle.close(); // clean up