2022-08-25 18:08:53 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Test exec() when a timeout is set, but not expired.
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const cp = require('child_process');
|
|
|
|
|
|
|
|
const {
|
|
|
|
cleanupStaleProcess,
|
|
|
|
logAfterTime
|
|
|
|
} = require('../common/child_process');
|
|
|
|
|
|
|
|
const kTimeoutNotSupposedToExpire = 2 ** 30;
|
|
|
|
const childRunTime = common.platformTimeout(100);
|
|
|
|
|
|
|
|
// The time spent in the child should be smaller than the timeout below.
|
|
|
|
assert(childRunTime < kTimeoutNotSupposedToExpire);
|
|
|
|
|
|
|
|
if (process.argv[2] === 'child') {
|
|
|
|
logAfterTime(childRunTime);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-09-29 22:44:52 +02:00
|
|
|
const [cmd, opts] = common.escapePOSIXShell`"${process.execPath}" "${__filename}" child`;
|
2022-08-25 18:08:53 +08:00
|
|
|
|
|
|
|
cp.exec(cmd, {
|
2024-09-29 22:44:52 +02:00
|
|
|
...opts,
|
|
|
|
timeout: kTimeoutNotSupposedToExpire,
|
2022-08-25 18:08:53 +08:00
|
|
|
}, common.mustSucceed((stdout, stderr) => {
|
|
|
|
assert.strictEqual(stdout.trim(), 'child stdout');
|
|
|
|
assert.strictEqual(stderr.trim(), 'child stderr');
|
|
|
|
}));
|
|
|
|
|
|
|
|
cleanupStaleProcess(__filename);
|