Skip to content

Commit

Permalink
test: use mustNotCall() in test-fs-watch
Browse files Browse the repository at this point in the history
Use common.mustNotCall() in test/sequential/test-fs-watch.js in
situations where the call to watch() is expected to throw.

PR-URL: #13595
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and MylesBorins committed Aug 16, 2017
1 parent 9356e96 commit 5e9b203
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions test/sequential/test-fs-watch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
const common = require('../common');
const assert = require('assert');
Expand Down Expand Up @@ -109,15 +130,15 @@ fs.watch(__filename, {persistent: false}, function() {
// https://github.com/joyent/node/issues/6690
let oldhandle;
assert.throws(function() {
const w = fs.watch(__filename, function(event, filename) { });
const w = fs.watch(__filename, common.mustNotCall());
oldhandle = w._handle;
w._handle = { close: w._handle.close };
w.close();
}, /^TypeError: Illegal invocation$/);
oldhandle.close(); // clean up

assert.throws(function() {
const w = fs.watchFile(__filename, {persistent: false}, common.noop);
const w = fs.watchFile(__filename, {persistent: false}, common.mustNotCall());
oldhandle = w._handle;
w._handle = { stop: w._handle.stop };
w.stop();
Expand Down

0 comments on commit 5e9b203

Please sign in to comment.