test: refactor test-vm-sigint
* 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: https://github.com/nodejs/node/pull/13902 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
62947916b6
commit
99dc9d03de
@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
const assert = require('assert');
|
||||
const vm = require('vm');
|
||||
|
||||
@ -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' ?
|
||||
@ -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\.$/);
|
||||
|
Loading…
x
Reference in New Issue
Block a user