mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 14:56:19 +00:00

ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. PR-URL: https://github.com/nodejs/node/pull/14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (common.isWindows) {
|
|
// No way to send CTRL_C_EVENT to processes from JS right now.
|
|
common.skip('platform not supported');
|
|
}
|
|
|
|
const assert = require('assert');
|
|
const vm = require('vm');
|
|
const spawn = require('child_process').spawn;
|
|
|
|
if (process.argv[2] === 'child') {
|
|
const method = process.argv[3];
|
|
const listeners = +process.argv[4];
|
|
assert.ok(method);
|
|
assert.ok(Number.isInteger(listeners));
|
|
|
|
const script = `process.send('${method}'); while(true) {}`;
|
|
const args = method === 'runInContext' ?
|
|
[vm.createContext({ process })] :
|
|
[];
|
|
const options = { breakOnSigint: true };
|
|
|
|
for (let i = 0; i < listeners; i++)
|
|
process.on('SIGINT', common.mustNotCall());
|
|
|
|
assert.throws(() => { vm[method](script, ...args, options); },
|
|
/^Error: Script execution interrupted\.$/);
|
|
return;
|
|
}
|
|
|
|
for (const method of ['runInThisContext', 'runInContext']) {
|
|
for (const listeners of [0, 1, 2]) {
|
|
const args = [__filename, 'child', method, listeners];
|
|
const child = spawn(process.execPath, args, {
|
|
stdio: [null, 'pipe', 'inherit', 'ipc']
|
|
});
|
|
|
|
child.on('message', common.mustCall(() => {
|
|
process.kill(child.pid, 'SIGINT');
|
|
}));
|
|
|
|
child.on('close', common.mustCall((code, signal) => {
|
|
assert.strictEqual(signal, null);
|
|
assert.strictEqual(code, 0);
|
|
}));
|
|
}
|
|
}
|