Skip to content

Commit

Permalink
test: add coverage for FSWatcher exception
Browse files Browse the repository at this point in the history
Cover an previously uncovered exception possible in the internal start
function for FSWatcher.

Signed-off-by: Rich Trott <rtrott@gmail.com>

PR-URL: nodejs#32057
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
  • Loading branch information
Trott committed Mar 5, 2020
1 parent 616a729 commit b1d4c13
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/sequential/test-fs-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1d4c13

Please sign in to comment.