From 09456341272984a2b41c9d39d8cd331d33109362 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Tue, 11 Feb 2025 14:00:38 +0900 Subject: [PATCH] test: clean up node_compat test runner (#28028) --- tests/node_compat/common.ts | 9 +++---- tests/node_compat/config.jsonc | 27 ++++++++++--------- tests/node_compat/polyfill_globals.js | 20 -------------- tests/node_compat/runner.ts | 14 ---------- tests/node_compat/test/fixtures/exit.js | 8 +++--- .../fixtures/parent-process-nonpersistent.js | 3 +-- .../node_compat/test/fixtures/print-chars.js | 8 +++--- .../parallel/test-child-process-detached.js | 6 ++--- .../test-child-process-exec-encoding.js | 13 ++++----- .../test-child-process-exec-kill-throws.js | 12 +++------ .../test-child-process-exec-std-encoding.js | 12 +++------ ...-child-process-exec-timeout-not-expired.js | 12 +++------ .../parallel/test-child-process-execfile.js | 26 ++++++++---------- .../parallel/test-child-process-exit-code.js | 11 +++----- .../test/parallel/test-child-process-ipc.js | 9 +++---- .../test-child-process-spawnsync-env.js | 12 +++------ .../test-child-process-stdio-inherit.js | 11 +++----- .../test-child-process-stdout-flush-exit.js | 12 +++------ .../test-child-process-stdout-flush.js | 9 +++---- .../parallel/test-stdin-from-file-spawn.js | 9 +++---- .../sequential/test-child-process-exit.js | 11 +++----- 21 files changed, 83 insertions(+), 171 deletions(-) delete mode 100644 tests/node_compat/polyfill_globals.js delete mode 100644 tests/node_compat/runner.ts diff --git a/tests/node_compat/common.ts b/tests/node_compat/common.ts index a86373d69f..ce50878e00 100644 --- a/tests/node_compat/common.ts +++ b/tests/node_compat/common.ts @@ -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 diff --git a/tests/node_compat/config.jsonc b/tests/node_compat/config.jsonc index 51ee6db3d9..29595981ee 100644 --- a/tests/node_compat/config.jsonc +++ b/tests/node_compat/config.jsonc @@ -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" diff --git a/tests/node_compat/polyfill_globals.js b/tests/node_compat/polyfill_globals.js deleted file mode 100644 index 8bbd5cc7df..0000000000 --- a/tests/node_compat/polyfill_globals.js +++ /dev/null @@ -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; diff --git a/tests/node_compat/runner.ts b/tests/node_compat/runner.ts deleted file mode 100644 index 6bc750447a..0000000000 --- a/tests/node_compat/runner.ts +++ /dev/null @@ -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); -} diff --git a/tests/node_compat/test/fixtures/exit.js b/tests/node_compat/test/fixtures/exit.js index ca80f48286..20c16af2f4 100644 --- a/tests/node_compat/test/fixtures/exit.js +++ b/tests/node_compat/test/fixtures/exit.js @@ -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); diff --git a/tests/node_compat/test/fixtures/parent-process-nonpersistent.js b/tests/node_compat/test/fixtures/parent-process-nonpersistent.js index 537478aac5..7aa0759ba6 100644 --- a/tests/node_compat/test/fixtures/parent-process-nonpersistent.js +++ b/tests/node_compat/test/fixtures/parent-process-nonpersistent.js @@ -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'), diff --git a/tests/node_compat/test/fixtures/print-chars.js b/tests/node_compat/test/fixtures/print-chars.js index 2519c77fd2..7617f7cd7d 100644 --- a/tests/node_compat/test/fixtures/print-chars.js +++ b/tests/node_compat/test/fixtures/print-chars.js @@ -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)); diff --git a/tests/node_compat/test/parallel/test-child-process-detached.js b/tests/node_compat/test/parallel/test-child-process-detached.js index 65ec207531..c931531804 100644 --- a/tests/node_compat/test/parallel/test-child-process-detached.js +++ b/tests/node_compat/test/parallel/test-child-process-detached.js @@ -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); diff --git a/tests/node_compat/test/parallel/test-child-process-exec-encoding.js b/tests/node_compat/test/parallel/test-child-process-exec-encoding.js index 2f261494a6..906a73212c 100644 --- a/tests/node_compat/test/parallel/test-child-process-exec-encoding.js +++ b/tests/node_compat/test/parallel/test-child-process-exec-encoding.js @@ -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); diff --git a/tests/node_compat/test/parallel/test-child-process-exec-kill-throws.js b/tests/node_compat/test/parallel/test-child-process-exec-kill-throws.js index 9d727bf641..42e7235d21 100644 --- a/tests/node_compat/test/parallel/test-child-process-exec-kill-throws.js +++ b/tests/node_compat/test/parallel/test-child-process-exec-kill-throws.js @@ -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) => { diff --git a/tests/node_compat/test/parallel/test-child-process-exec-std-encoding.js b/tests/node_compat/test/parallel/test-child-process-exec-std-encoding.js index e2f5452b38..d8569dca88 100644 --- a/tests/node_compat/test/parallel/test-child-process-exec-std-encoding.js +++ b/tests/node_compat/test/parallel/test-child-process-exec-std-encoding.js @@ -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); diff --git a/tests/node_compat/test/parallel/test-child-process-exec-timeout-not-expired.js b/tests/node_compat/test/parallel/test-child-process-exec-timeout-not-expired.js index d140bcbdd8..4f07ebda80 100644 --- a/tests/node_compat/test/parallel/test-child-process-exec-timeout-not-expired.js +++ b/tests/node_compat/test/parallel/test-child-process-exec-timeout-not-expired.js @@ -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 diff --git a/tests/node_compat/test/parallel/test-child-process-execfile.js b/tests/node_compat/test/parallel/test-child-process-execfile.js index df04e447f6..a42fe7c40d 100644 --- a/tests/node_compat/test/parallel/test-child-process-execfile.js +++ b/tests/node_compat/test/parallel/test-child-process-execfile.js @@ -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(). diff --git a/tests/node_compat/test/parallel/test-child-process-exit-code.js b/tests/node_compat/test/parallel/test-child-process-exit-code.js index 47309fb9c0..24b5bb6d6c 100644 --- a/tests/node_compat/test/parallel/test-child-process-exit-code.js +++ b/tests/node_compat/test/parallel/test-child-process-exit-code.js @@ -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); diff --git a/tests/node_compat/test/parallel/test-child-process-ipc.js b/tests/node_compat/test/parallel/test-child-process-ipc.js index 163ee56aa4..9474b24ed3 100644 --- a/tests/node_compat/test/parallel/test-child-process-ipc.js +++ b/tests/node_compat/test/parallel/test-child-process-ipc.js @@ -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()); diff --git a/tests/node_compat/test/parallel/test-child-process-spawnsync-env.js b/tests/node_compat/test/parallel/test-child-process-spawnsync-env.js index ca7c7fcdd7..fa9df7d27f 100644 --- a/tests/node_compat/test/parallel/test-child-process-spawnsync-env.js +++ b/tests/node_compat/test/parallel/test-child-process-spawnsync-env.js @@ -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 }) }); diff --git a/tests/node_compat/test/parallel/test-child-process-stdio-inherit.js b/tests/node_compat/test/parallel/test-child-process-stdio-inherit.js index 4a260b2876..281ae39d0f 100644 --- a/tests/node_compat/test/parallel/test-child-process-stdio-inherit.js +++ b/tests/node_compat/test/parallel/test-child-process-stdio-inherit.js @@ -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'; diff --git a/tests/node_compat/test/parallel/test-child-process-stdout-flush-exit.js b/tests/node_compat/test/parallel/test-child-process-stdout-flush-exit.js index 58e97eb433..9f417bc1c7 100644 --- a/tests/node_compat/test/parallel/test-child-process-stdout-flush-exit.js +++ b/tests/node_compat/test/parallel/test-child-process-stdout-flush-exit.js @@ -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 = ''; diff --git a/tests/node_compat/test/parallel/test-child-process-stdout-flush.js b/tests/node_compat/test/parallel/test-child-process-stdout-flush.js index 983ccefda7..9ef210e5b1 100644 --- a/tests/node_compat/test/parallel/test-child-process-stdout-flush.js +++ b/tests/node_compat/test/parallel/test-child-process-stdout-flush.js @@ -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; diff --git a/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js b/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js index 2f6b418982..9e65d8d8e7 100644 --- a/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js +++ b/tests/node_compat/test/parallel/test-stdin-from-file-spawn.js @@ -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}`); diff --git a/tests/node_compat/test/sequential/test-child-process-exit.js b/tests/node_compat/test/sequential/test-child-process-exit.js index 01910d72fc..e7ab767163 100644 --- a/tests/node_compat/test/sequential/test-child-process-exit.js +++ b/tests/node_compat/test/sequential/test-child-process-exit.js @@ -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);