mirror of
https://github.com/denoland/deno.git
synced 2025-02-16 02:26:08 -05:00
test: clean up node_compat test runner (#28028)
This commit is contained in:
parent
174e496847
commit
0945634127
21 changed files with 83 additions and 171 deletions
|
@ -161,14 +161,11 @@ export async function runNodeCompatTestCase(
|
|||
"--unstable-unsafe-proto",
|
||||
"--unstable-bare-node-builtins",
|
||||
"--unstable-fs",
|
||||
"--unstable-node-globals",
|
||||
"--v8-flags=" + v8Flags.join(),
|
||||
"--no-check",
|
||||
testCase,
|
||||
];
|
||||
if (usesNodeTest) {
|
||||
// deno test typechecks by default + we want to pass script args
|
||||
args.push("--no-check", "runner.ts", "--", testCase);
|
||||
} else {
|
||||
args.push("runner.ts", testCase);
|
||||
}
|
||||
|
||||
// Pipe stdout in order to output each test result as Deno.test output
|
||||
// That way the tests will respect the `--quiet` option when provided
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
"echo.js",
|
||||
"elipses.txt",
|
||||
"empty.txt",
|
||||
"exit.js",
|
||||
"parent-process-nonpersistent.js",
|
||||
"print-chars.js",
|
||||
"x.txt"
|
||||
],
|
||||
"internet": [
|
||||
|
@ -28,10 +25,8 @@
|
|||
"test-buffer-from.js",
|
||||
"test-buffer-includes.js",
|
||||
"test-buffer-indexof.js",
|
||||
"test-child-process-detached.js",
|
||||
"test-child-process-exec-abortcontroller-promisified.js",
|
||||
"test-child-process-exec-encoding.js",
|
||||
"test-child-process-exec-kill-throws.js",
|
||||
"test-child-process-exec-maxbuf.js",
|
||||
"test-child-process-exec-std-encoding.js",
|
||||
// TODO(bartlomieju): this test was flaky on macOS CI
|
||||
|
@ -41,15 +36,9 @@
|
|||
"test-child-process-exec-timeout-not-expired.js",
|
||||
"test-child-process-execfile.js",
|
||||
"test-child-process-execsync-maxbuf.js",
|
||||
"test-child-process-exit-code.js",
|
||||
// TODO(littledivy): windows ipc streams not yet implemented
|
||||
"test-child-process-fork-ref.js",
|
||||
"test-child-process-fork-ref2.js",
|
||||
"test-child-process-ipc.js",
|
||||
"test-child-process-spawnsync-env.js",
|
||||
"test-child-process-stdio-inherit.js",
|
||||
"test-child-process-stdout-flush-exit.js",
|
||||
"test-child-process-stdout-flush.js",
|
||||
"test-console-instance.js",
|
||||
"test-crypto-dh.js",
|
||||
"test-crypto-hkdf.js",
|
||||
|
@ -119,8 +108,7 @@
|
|||
"test-zlib-zero-byte.js",
|
||||
"test-zlib-zero-windowBits.js"
|
||||
],
|
||||
"pummel": [],
|
||||
"sequential": ["test-child-process-exit.js"]
|
||||
"pummel": []
|
||||
},
|
||||
"tests": {
|
||||
"abort": [
|
||||
|
@ -162,6 +150,7 @@
|
|||
"exit.js",
|
||||
"GH-1899-output.js",
|
||||
"loop.js",
|
||||
"parent-process-nonpersistent.js",
|
||||
"print-chars.js",
|
||||
"sample.png",
|
||||
"x.txt"
|
||||
|
@ -256,37 +245,48 @@
|
|||
// TODO(bartlomieju): this test was flaky on macOS CI
|
||||
// "test-child-process-can-write-to-stdout.js",
|
||||
"test-child-process-default-options.js",
|
||||
"test-child-process-detached.js",
|
||||
"test-child-process-double-pipe.js",
|
||||
"test-child-process-exec-abortcontroller-promisified.js",
|
||||
"test-child-process-exec-cwd.js",
|
||||
"test-child-process-exec-encoding.js",
|
||||
"test-child-process-exec-env.js",
|
||||
"test-child-process-exec-error.js",
|
||||
"test-child-process-exec-kill-throws.js",
|
||||
"test-child-process-exec-maxbuf.js",
|
||||
"test-child-process-exec-std-encoding.js",
|
||||
"test-child-process-exec-stdout-stderr-data-string.js",
|
||||
// TODO(bartlomieju): this test was flaky on macOS CI
|
||||
// "test-child-process-exec-timeout-expire.js",
|
||||
// TODO(bartlomieju): this test was flaky on macOS CI
|
||||
// "test-child-process-exec-timeout-kill.js",
|
||||
"test-child-process-exec-timeout-not-expired.js",
|
||||
// TODO(bartlomieju): this test was flaky on macOS CI
|
||||
// "test-child-process-execFile-promisified-abortController.js",
|
||||
"test-child-process-execfile-maxbuf.js",
|
||||
"test-child-process-execfile.js",
|
||||
"test-child-process-execfilesync-maxbuf.js",
|
||||
"test-child-process-execsync-maxbuf.js",
|
||||
"test-child-process-exit-code.js",
|
||||
"test-child-process-flush-stdio.js",
|
||||
"test-child-process-fork3.js",
|
||||
"test-child-process-ipc-next-tick.js",
|
||||
"test-child-process-ipc.js",
|
||||
"test-child-process-kill.js",
|
||||
"test-child-process-send-type-error.js",
|
||||
"test-child-process-set-blocking.js",
|
||||
"test-child-process-spawn-args.js",
|
||||
"test-child-process-spawn-event.js",
|
||||
"test-child-process-spawnsync-args.js",
|
||||
"test-child-process-spawnsync-env.js",
|
||||
"test-child-process-spawnsync-maxbuf.js",
|
||||
"test-child-process-spawnsync-validation-errors.js",
|
||||
"test-child-process-spawnsync.js",
|
||||
"test-child-process-stdin-ipc.js",
|
||||
"test-child-process-stdio-inherit.js",
|
||||
"test-child-process-stdio-overlapped.js",
|
||||
"test-child-process-stdout-flush-exit.js",
|
||||
"test-child-process-stdout-flush.js",
|
||||
"test-client-request-destroy.js",
|
||||
"test-cluster-uncaught-exception.js",
|
||||
"test-console-assign-undefined.js",
|
||||
|
@ -1327,6 +1327,7 @@
|
|||
"test-net-pipe-connect-errors.js",
|
||||
"test-net-server-listen-path.js",
|
||||
"test-net-socket-close-after-end.js",
|
||||
"test-spawn-cmd-named-pipe.js",
|
||||
"test-util-inspect-long-running.js",
|
||||
"test-util-inspect.js",
|
||||
"test-vm-low-stack-space.js"
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright 2018-2025 the Deno authors. MIT license.
|
||||
import { Buffer } from "node:buffer";
|
||||
import {
|
||||
clearImmediate,
|
||||
clearInterval,
|
||||
clearTimeout,
|
||||
setImmediate,
|
||||
setInterval,
|
||||
setTimeout,
|
||||
} from "node:timers";
|
||||
import { performance } from "node:perf_hooks";
|
||||
globalThis.Buffer = Buffer;
|
||||
globalThis.clearImmediate = clearImmediate;
|
||||
globalThis.clearInterval = clearInterval;
|
||||
globalThis.clearTimeout = clearTimeout;
|
||||
globalThis.global = globalThis;
|
||||
globalThis.performance = performance;
|
||||
globalThis.setImmediate = setImmediate;
|
||||
globalThis.setInterval = setInterval;
|
||||
globalThis.setTimeout = setTimeout;
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2018-2025 the Deno authors. MIT license.
|
||||
import "./polyfill_globals.js";
|
||||
import { createRequire } from "node:module";
|
||||
import { toFileUrl } from "@std/path/to-file-url";
|
||||
const file = Deno.args[0];
|
||||
if (!file) {
|
||||
throw new Error("No file provided");
|
||||
}
|
||||
|
||||
if (file.endsWith(".mjs")) {
|
||||
await import(toFileUrl(file).href);
|
||||
} else {
|
||||
createRequire(import.meta.url)(file);
|
||||
}
|
8
tests/node_compat/test/fixtures/exit.js
vendored
8
tests/node_compat/test/fixtures/exit.js
vendored
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,6 +26,4 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] should be argv[2].
|
||||
|
||||
process.exit(process.argv[3] || 1);
|
||||
process.exit(process.argv[2] || 1);
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Modified to add `runner.ts` to inject `require` into subprocess
|
||||
|
||||
const spawn = require('child_process').spawn,
|
||||
path = require('path'),
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,10 +26,8 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] should be argv[2].
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
var n = parseInt(process.argv[3]);
|
||||
var n = parseInt(process.argv[2]);
|
||||
|
||||
process.stdout.write('c'.repeat(n));
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
|
@ -26,8 +26,6 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// Modified to add `runner.ts` to inject `require` into subprocess
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
@ -37,7 +35,7 @@ const spawn = require('child_process').spawn;
|
|||
const childPath = fixtures.path('parent-process-nonpersistent.js');
|
||||
let persistentPid = -1;
|
||||
|
||||
const child = spawn(process.execPath, [ "runner.ts", childPath ]);
|
||||
const child = spawn(process.execPath, [ childPath ]);
|
||||
|
||||
child.stdout.on('data', function(data) {
|
||||
persistentPid = parseInt(data, 10);
|
||||
|
|
|
@ -2,19 +2,15 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.8.0
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] check should be argv[2], and the
|
||||
// command passed to exec() should not need to include "run", "-A",
|
||||
// and "runner.ts".
|
||||
// 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';
|
||||
const common = require('../common');
|
||||
const stdoutData = 'foo';
|
||||
const stderrData = 'bar';
|
||||
|
||||
if (process.argv[3] === 'child') {
|
||||
if (process.argv[2] === 'child') {
|
||||
// The following console calls are part of the test.
|
||||
console.log(stdoutData);
|
||||
console.error(stderrData);
|
||||
|
@ -24,7 +20,8 @@ if (process.argv[3] === 'child') {
|
|||
const expectedStdout = `${stdoutData}\n`;
|
||||
const expectedStderr = `${stderrData}\n`;
|
||||
function run(options, callback) {
|
||||
const cmd = `"${process.execPath}" run -A runner.ts "${__filename}" child`;
|
||||
// FIXME(kt3k): needs to add --allow-read permission to child process
|
||||
const cmd = `"${process.execPath}" --allow-read "${__filename}" child`;
|
||||
|
||||
cp.exec(cmd, options, common.mustSucceed((stdout, stderr) => {
|
||||
callback(stdout, stderr);
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.8.0
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] check should be argv[2], and the
|
||||
// command passed to exec() should not need to include "run", "-A",
|
||||
// and "runner.ts".
|
||||
// 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';
|
||||
// Flags: --expose-internals
|
||||
|
@ -15,7 +11,7 @@ const common = require('../common');
|
|||
const assert = require('assert');
|
||||
const cp = require('child_process');
|
||||
|
||||
if (process.argv[3] === 'child') {
|
||||
if (process.argv[2] === 'child') {
|
||||
// Since maxBuffer is 0, this should trigger an error.
|
||||
console.log('foo');
|
||||
} else {
|
||||
|
@ -29,7 +25,7 @@ if (process.argv[3] === 'child') {
|
|||
throw new Error('mock error');
|
||||
};
|
||||
|
||||
const cmd = `"${process.execPath}" run -A runner.ts "${__filename}" child`;
|
||||
const cmd = `"${process.execPath}" "${__filename}" child`;
|
||||
const options = { maxBuffer: 0, killSignal: 'SIGKILL' };
|
||||
|
||||
const child = cp.exec(cmd, options, common.mustCall((err, stdout, stderr) => {
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.8.0
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] check should be argv[2], and the
|
||||
// command passed to exec() should not need to include "run", "-A",
|
||||
// and "runner.ts".
|
||||
// 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';
|
||||
const common = require('../common');
|
||||
|
@ -18,12 +14,12 @@ const stderrData = 'bar';
|
|||
const expectedStdout = `${stdoutData}\n`;
|
||||
const expectedStderr = `${stderrData}\n`;
|
||||
|
||||
if (process.argv[3] === 'child') {
|
||||
if (process.argv[2] === 'child') {
|
||||
// The following console calls are part of the test.
|
||||
console.log(stdoutData);
|
||||
console.error(stderrData);
|
||||
} else {
|
||||
const cmd = `"${process.execPath}" run -A runner.ts "${__filename}" child`;
|
||||
const cmd = `"${process.execPath}" --allow-read "${__filename}" child`;
|
||||
const child = cp.exec(cmd, common.mustSucceed((stdout, stderr) => {
|
||||
assert.strictEqual(stdout, expectedStdout);
|
||||
assert.strictEqual(stderr, expectedStderr);
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] check should be argv[2], and the
|
||||
// command passed to exec() should not need to include "run", "-A",
|
||||
// and "runner.ts".
|
||||
// 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';
|
||||
|
||||
|
@ -28,12 +24,12 @@ const childRunTime = common.platformTimeout(100);
|
|||
// The time spent in the child should be smaller than the timeout below.
|
||||
assert(childRunTime < kTimeoutNotSupposedToExpire);
|
||||
|
||||
if (process.argv[3] === 'child') {
|
||||
if (process.argv[2] === 'child') {
|
||||
logAfterTime(childRunTime);
|
||||
return;
|
||||
}
|
||||
|
||||
const cmd = `"${process.execPath}" run -A runner.ts "${__filename}" child`;
|
||||
const cmd = `"${process.execPath}" --allow-read "${__filename}" child`;
|
||||
|
||||
cp.exec(cmd, {
|
||||
timeout: kTimeoutNotSupposedToExpire
|
||||
|
|
|
@ -2,19 +2,15 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.8.0
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
|
||||
// TODO(PolarETech): The args passed to execFile() should not need to
|
||||
// include "runner.ts".
|
||||
|
||||
// TODO(cjihrig): See inline TODO comments below.
|
||||
// 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';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { execFile, execFileSync } = require('child_process');
|
||||
const { getEventListeners } = require('events');
|
||||
const { getSystemErrorName } = require('util');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const os = require('os');
|
||||
|
@ -26,11 +22,11 @@ const execOpts = { encoding: 'utf8', shell: true };
|
|||
{
|
||||
execFile(
|
||||
process.execPath,
|
||||
['runner.ts', fixture, 42],
|
||||
[fixture, 42],
|
||||
common.mustCall((e) => {
|
||||
// Check that arguments are included in message
|
||||
assert.strictEqual(e.message.trim(),
|
||||
`Command failed: ${process.execPath} runner.ts ${fixture} 42`);
|
||||
`Command failed: ${process.execPath} ${fixture} 42`);
|
||||
assert.strictEqual(e.code, 42);
|
||||
})
|
||||
);
|
||||
|
@ -57,7 +53,7 @@ const execOpts = { encoding: 'utf8', shell: true };
|
|||
|
||||
{
|
||||
// Verify the shell option works properly
|
||||
execFile(process.execPath, ['runner.ts', fixture, 0], execOpts, common.mustSucceed());
|
||||
execFile(process.execPath, [fixture, 0], execOpts, common.mustSucceed());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -71,7 +67,7 @@ const execOpts = { encoding: 'utf8', shell: true };
|
|||
assert.strictEqual(err.name, 'AbortError');
|
||||
assert.strictEqual(err.signal, undefined);
|
||||
});
|
||||
execFile(process.execPath, ['runner.ts', echoFixture, 0], { signal }, check);
|
||||
execFile(process.execPath, [echoFixture, 0], { signal }, check);
|
||||
};
|
||||
|
||||
// Verify that it still works the same way now that the signal is aborted.
|
||||
|
@ -88,16 +84,16 @@ const execOpts = { encoding: 'utf8', shell: true };
|
|||
assert.strictEqual(err.name, 'AbortError');
|
||||
assert.strictEqual(err.signal, undefined);
|
||||
});
|
||||
execFile(process.execPath, ['runner.ts', echoFixture, 0], { signal }, check);
|
||||
execFile(process.execPath, [echoFixture, 0], { signal }, check);
|
||||
}
|
||||
|
||||
{
|
||||
// Verify that if something different than Abortcontroller.signal
|
||||
// is passed, ERR_INVALID_ARG_TYPE is thrown
|
||||
assert.throws(() => {
|
||||
const callback = common.mustNotCall(() => {});
|
||||
const callback = common.mustNotCall();
|
||||
|
||||
execFile(process.execPath, ['runner.ts', echoFixture, 0], { signal: 'hello' }, callback);
|
||||
execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback);
|
||||
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||
}
|
||||
{
|
||||
|
@ -111,7 +107,7 @@ const execOpts = { encoding: 'utf8', shell: true };
|
|||
// assert.strictEqual(getEventListeners(ac.signal).length, 0);
|
||||
assert.strictEqual(err, null);
|
||||
});
|
||||
execFile(process.execPath, ['runner.ts', fixture, 0], { signal }, callback);
|
||||
execFile(process.execPath, [fixture, 0], { signal }, callback);
|
||||
}
|
||||
|
||||
// Verify the execFile() stdout is the same as execFileSync().
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,9 +26,6 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(PolarETech): The args passed to spawn() should not need to
|
||||
// include "runner.ts".
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
@ -36,7 +33,7 @@ const spawn = require('child_process').spawn;
|
|||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const exitScript = fixtures.path('exit.js');
|
||||
const exitChild = spawn(process.argv[0], ['runner.ts', exitScript, 23]);
|
||||
const exitChild = spawn(process.argv[0], [exitScript, 23]);
|
||||
exitChild.on('exit', common.mustCall(function(code, signal) {
|
||||
assert.strictEqual(code, 23);
|
||||
assert.strictEqual(signal, null);
|
||||
|
@ -44,7 +41,7 @@ exitChild.on('exit', common.mustCall(function(code, signal) {
|
|||
|
||||
|
||||
const errorScript = fixtures.path('child_process_should_emit_error.js');
|
||||
const errorChild = spawn(process.argv[0], ['runner.ts', errorScript]);
|
||||
const errorChild = spawn(process.argv[0], [errorScript]);
|
||||
errorChild.on('exit', common.mustCall(function(code, signal) {
|
||||
assert.ok(code !== 0);
|
||||
assert.strictEqual(signal, null);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,9 +26,6 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(PolarETech): The args passed to spawn() should not need to
|
||||
// include "runner.ts".
|
||||
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
|
@ -43,7 +40,7 @@ const fixtures = require('../common/fixtures');
|
|||
|
||||
const sub = fixtures.path('echo.js');
|
||||
|
||||
const child = spawn(process.argv[0], ['runner.ts', sub]);
|
||||
const child = spawn(process.argv[0], [sub]);
|
||||
|
||||
child.stderr.on('data', mustNotCall());
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.8.0
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,20 +26,16 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(cjihrig): The process.argv[3] check should be argv[2], and the
|
||||
// arguments array passed to spawnSync() should not need to include
|
||||
// "runner.ts".
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const cp = require('child_process');
|
||||
|
||||
if (process.argv[3] === 'child') {
|
||||
if (process.argv[2] === 'child') {
|
||||
console.log(process.env.foo);
|
||||
} else {
|
||||
const expected = 'bar';
|
||||
const child = cp.spawnSync(process.execPath, ["runner.ts", __filename, 'child'], {
|
||||
const child = cp.spawnSync(process.execPath, [__filename, 'child'], {
|
||||
env: Object.assign(process.env, { foo: expected })
|
||||
});
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,21 +26,18 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] check should be argv[2], and
|
||||
// the args passed to spawn() should not need to include "runner.ts".
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
if (process.argv[3] === 'parent')
|
||||
if (process.argv[2] === 'parent')
|
||||
parent();
|
||||
else
|
||||
grandparent();
|
||||
|
||||
function grandparent() {
|
||||
const child = spawn(process.execPath, ['runner.ts', __filename, 'parent']);
|
||||
const child = spawn(process.execPath, [__filename, 'parent']);
|
||||
child.stderr.pipe(process.stderr);
|
||||
let output = '';
|
||||
const input = 'asdfasdf';
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,17 +26,13 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] check should be argv[2],
|
||||
// the args passed to spawn() should not need to include "runner.ts",
|
||||
// and the process.argv[2] passed to spawn() should be argv[1].
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
// If child process output to console and exit
|
||||
// The console.log statements here are part of the test.
|
||||
if (process.argv[3] === 'child') {
|
||||
if (process.argv[2] === 'child') {
|
||||
console.log('hello');
|
||||
for (let i = 0; i < 200; i++) {
|
||||
console.log('filler');
|
||||
|
@ -48,7 +44,7 @@ if (process.argv[3] === 'child') {
|
|||
const spawn = require('child_process').spawn;
|
||||
|
||||
// spawn self as child
|
||||
const child = spawn(process.argv[0], ['runner.ts', process.argv[2], 'child']);
|
||||
const child = spawn(process.argv[0], [process.argv[1], 'child']);
|
||||
|
||||
let stdout = '';
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,9 +26,6 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(PolarETech): The args passed to spawn() should not need to
|
||||
// include "runner.ts".
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
@ -39,7 +36,7 @@ const sub = fixtures.path('print-chars.js');
|
|||
|
||||
const n = 500000;
|
||||
|
||||
const child = spawn(process.argv[0], ['runner.ts', sub, n]);
|
||||
const child = spawn(process.argv[0], [sub, n]);
|
||||
|
||||
let count = 0;
|
||||
|
||||
|
|
|
@ -2,11 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.8.0
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
|
||||
// TODO(cjihrig): 'run -A runner.ts' should not be needed in
|
||||
// execSync() call at the bottom of this test.
|
||||
// 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';
|
||||
const common = require('../common');
|
||||
|
@ -49,4 +46,4 @@ setTimeout(() => {
|
|||
}, 100);
|
||||
`);
|
||||
|
||||
execSync(`${process.argv[0]} run -A runner.ts ${tmpJsFile} < ${tmpCmdFile}`);
|
||||
execSync(`${process.argv[0]} -A ${tmpJsFile} < ${tmpCmdFile}`);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 18.12.1
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
// Taken from Node 20.11.1
|
||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
@ -26,9 +26,6 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// TODO(PolarETech): The process.argv[3] to be assigned to gen should be argv[2],
|
||||
// and the arguments array passed to spawn() should not need to include "runner.ts".
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
|
@ -40,7 +37,7 @@ require('../common');
|
|||
const assert = require('assert');
|
||||
const ch = require('child_process');
|
||||
|
||||
const gen = +(process.argv[3] || 0);
|
||||
const gen = +(process.argv[2] || 0);
|
||||
const maxGen = 5;
|
||||
|
||||
|
||||
|
@ -49,7 +46,7 @@ if (gen === maxGen) {
|
|||
return;
|
||||
}
|
||||
|
||||
const child = ch.spawn(process.execPath, ['runner.ts', __filename, gen + 1], {
|
||||
const child = ch.spawn(process.execPath, [__filename, gen + 1], {
|
||||
stdio: [ 'ignore', 'pipe', 'ignore' ]
|
||||
});
|
||||
assert.ok(!child.stdin);
|
||||
|
|
Loading…
Add table
Reference in a new issue