Skip to content

Commit

Permalink
test: refactor test-vm-sigint
Browse files Browse the repository at this point in the history
* Use common.mustNotCall() to confirm SIGINT listeners are not being
  invoked.
* Improve assertion check on integer child argument.
* Add blank line per test writing guide.

PR-URL: #13902
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and addaleax committed Jul 18, 2017
1 parent 949d1b1 commit 98ec8aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-vm-sigint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const common = require('../common');

const assert = require('assert');
const vm = require('vm');

Expand All @@ -15,7 +16,7 @@ if (process.argv[2] === 'child') {
const method = process.argv[3];
const listeners = +process.argv[4];
assert.ok(method);
assert.ok(typeof listeners, 'number');
assert.ok(Number.isInteger(listeners));

const script = `process.send('${method}'); while(true) {}`;
const args = method === 'runInContext' ?
Expand All @@ -24,7 +25,7 @@ if (process.argv[2] === 'child') {
const options = { breakOnSigint: true };

for (let i = 0; i < listeners; i++)
process.on('SIGINT', common.noop);
process.on('SIGINT', common.mustNotCall());

assert.throws(() => { vm[method](script, ...args, options); },
/^Error: Script execution interrupted\.$/);
Expand Down

0 comments on commit 98ec8aa

Please sign in to comment.