mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

On Windows it might take too long for the parent to start the communication with a child process, so by the time the parent starts its own timer, the child process might have already completed running, and the parent in those tests won't have a chance to terminate these child processes after the timeout. To address this issue, raise the time for which the child is supposed to run to make sure that the parent starts its own timer before the child terminates in the tests. Also, split the test into smaller ones to reduce the overhead. PR-URL: https://github.com/nodejs/node/pull/44390 Refs: https://github.com/nodejs/reliability/issues/356 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
40 lines
983 B
JavaScript
40 lines
983 B
JavaScript
'use strict';
|
|
|
|
// Test exec() with both a timeout and a killSignal.
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cp = require('child_process');
|
|
|
|
const {
|
|
cleanupStaleProcess,
|
|
logInTimeout,
|
|
kExpiringChildRunTime,
|
|
kExpiringParentTimer,
|
|
} = require('../common/child_process');
|
|
|
|
if (process.argv[2] === 'child') {
|
|
logInTimeout(kExpiringChildRunTime);
|
|
return;
|
|
}
|
|
|
|
const cmd = `"${process.execPath}" "${__filename}" child`;
|
|
|
|
// Test with a different kill signal.
|
|
cp.exec(cmd, {
|
|
timeout: kExpiringParentTimer,
|
|
killSignal: 'SIGKILL'
|
|
}, common.mustCall((err, stdout, stderr) => {
|
|
console.log('[stdout]', stdout.trim());
|
|
console.log('[stderr]', stderr.trim());
|
|
|
|
assert.strictEqual(err.killed, true);
|
|
assert.strictEqual(err.code, null);
|
|
assert.strictEqual(err.signal, 'SIGKILL');
|
|
assert.strictEqual(err.cmd, cmd);
|
|
assert.strictEqual(stdout.trim(), '');
|
|
assert.strictEqual(stderr.trim(), '');
|
|
}));
|
|
|
|
cleanupStaleProcess(__filename);
|