1'use strict'; 2 3// Test exec() when a timeout is set, but not expired. 4 5const common = require('../common'); 6const assert = require('assert'); 7const cp = require('child_process'); 8 9const { 10 cleanupStaleProcess, 11 logAfterTime 12} = require('../common/child_process'); 13 14const kTimeoutNotSupposedToExpire = 2 ** 30; 15const childRunTime = common.platformTimeout(100); 16 17// The time spent in the child should be smaller than the timeout below. 18assert(childRunTime < kTimeoutNotSupposedToExpire); 19 20if (process.argv[2] === 'child') { 21 logAfterTime(childRunTime); 22 return; 23} 24 25const cmd = `"${process.execPath}" "${__filename}" child`; 26 27cp.exec(cmd, { 28 timeout: kTimeoutNotSupposedToExpire 29}, common.mustSucceed((stdout, stderr) => { 30 assert.strictEqual(stdout.trim(), 'child stdout'); 31 assert.strictEqual(stderr.trim(), 'child stderr'); 32})); 33 34cleanupStaleProcess(__filename); 35