0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-23 13:43:31 -05:00
denoland-deno/tests/node_compat/test/parallel/test-child-process-exec-timeout-not-expired.js
2025-02-11 14:00:38 +09:00

41 lines
1.1 KiB
JavaScript

// deno-fmt-ignore-file
// deno-lint-ignore-file
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
// Taken from Node 20.11.1
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
'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;
}
const cmd = `"${process.execPath}" --allow-read "${__filename}" child`;
cp.exec(cmd, {
timeout: kTimeoutNotSupposedToExpire
}, common.mustSucceed((stdout, stderr) => {
assert.strictEqual(stdout.trim(), 'child stdout');
assert.strictEqual(stderr.trim(), 'child stderr');
}));
cleanupStaleProcess(__filename);