| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 96b91dc commit 235a0ba
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ const { | |||
| 34 | 34 | verify, | |
| 35 | 35 | } = require('crypto'); | |
| 36 | 36 | const tmpdir = require('../common/tmpdir'); | |
| 37 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 37 | 38 | ||
| 38 | 39 | const { subtle } = globalThis.crypto; | |
| 39 | 40 | const kData = Buffer.from( | |
@@ -65,15 +66,14 @@ function softhsmOptions() { | |||
| 65 | 66 | ||
| 66 | 67 | function runInChild() { | |
| 67 | 68 | const { cwd, env } = softhsmOptions(); | |
| 68 | - const child = spawnSync(process.execPath, [ | ||
| 69 | + spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 69 | 70 | `--openssl-config=${kOpenSSLConfig}`, | |
| 70 | 71 | __filename, | |
| 71 | 72 | ], { | |
| 72 | 73 | cwd, | |
| 73 | 74 | env: { ...process.env, ...env, NODE_TEST_PKCS11_CHILD: '1' }, | |
| 74 | 75 | stdio: 'inherit', | |
| 75 | 76 | }); | |
| 76 | - assert.strictEqual(child.status, 0); | ||
| 77 | 77 | } | |
| 78 | 78 | ||
| 79 | 79 | function privateKeyUrl(label) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | const assert = require('assert'); | |
| 4 | - const { spawnSync } = require('child_process'); | ||
| 5 | 4 | const { Worker, parentPort } = require('worker_threads'); | |
| 5 | + const { spawnSyncAndAssert } = require('../common/child_process'); | ||
| 6 | 6 | ||
| 7 | 7 | if (process.env.TEST_CHILD_PROCESS === '1') { | |
| 8 | 8 | // Do not use isMainThread so that this test itself can be run inside a Worker. | |
@@ -29,10 +29,10 @@ if (process.env.TEST_CHILD_PROCESS === '1') { | |||
| 29 | 29 | ||
| 30 | 30 | const args = ['--harmony-struct', __filename]; | |
| 31 | 31 | const options = { env: { TEST_CHILD_PROCESS: '1', ...process.env } }; | |
| 32 | - const child = spawnSync(process.execPath, args, options); | ||
| 33 | 32 | ||
| 34 | - assert.strictEqual(child.stderr.toString().trim(), ''); | ||
| 35 | - assert.strictEqual(child.stdout.toString().trim(), ''); | ||
| 36 | - assert.strictEqual(child.status, 0); | ||
| 37 | - assert.strictEqual(child.signal, null); | ||
| 33 | + spawnSyncAndAssert(process.execPath, args, options, { | ||
| 34 | + stdout: '', | ||
| 35 | + stderr: '', | ||
| 36 | + trim: true | ||
| 37 | + }); | ||
| 38 | 38 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ const fixtures = require('../common/fixtures'); | |||
| 9 | 9 | common.skipIfInspectorDisabled(); | |
| 10 | 10 | ||
| 11 | 11 | const assert = require('assert'); | |
| 12 | - const { spawnSync } = require('child_process'); | ||
| 12 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 13 | 13 | ||
| 14 | 14 | const tmpdir = require('../common/tmpdir'); | |
| 15 | 15 | ||
@@ -20,18 +20,13 @@ const { | |||
| 20 | 20 | ||
| 21 | 21 | { | |
| 22 | 22 | tmpdir.refresh(); | |
| 23 | - const output = spawnSync(process.execPath, [ | ||
| 23 | + spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 24 | 24 | '--heap-prof', | |
| 25 | 25 | fixtures.path('workload', 'allocation.js'), | |
| 26 | 26 | ], { | |
| 27 | 27 | cwd: tmpdir.path, | |
| 28 | 28 | env | |
| 29 | 29 | }); | |
| 30 | - if (output.status !== 0) { | ||
| 31 | - console.log(output.stderr.toString()); | ||
| 32 | - console.log(output); | ||
| 33 | - } | ||
| 34 | - assert.strictEqual(output.status, 0); | ||
| 35 | 30 | const profiles = getHeapProfiles(tmpdir.path); | |
| 36 | 31 | assert.strictEqual(profiles.length, 1); | |
| 37 | 32 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ const fixtures = require('../common/fixtures'); | |||
| 9 | 9 | common.skipIfInspectorDisabled(); | |
| 10 | 10 | ||
| 11 | 11 | const assert = require('assert'); | |
| 12 | - const { spawnSync } = require('child_process'); | ||
| 12 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 13 | 13 | ||
| 14 | 14 | const tmpdir = require('../common/tmpdir'); | |
| 15 | 15 | ||
@@ -20,7 +20,7 @@ const { | |||
| 20 | 20 | ||
| 21 | 21 | { | |
| 22 | 22 | tmpdir.refresh(); | |
| 23 | - const output = spawnSync(process.execPath, [ | ||
| 23 | + const { child: output } = spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 24 | 24 | fixtures.path('workload', 'allocation-worker-argv.js'), | |
| 25 | 25 | ], { | |
| 26 | 26 | cwd: tmpdir.path, | |
@@ -29,10 +29,6 @@ const { | |||
| 29 | 29 | HEAP_PROF_INTERVAL: '128' | |
| 30 | 30 | } | |
| 31 | 31 | }); | |
| 32 | - if (output.status !== 0) { | ||
| 33 | - console.log(output.stderr.toString()); | ||
| 34 | - } | ||
| 35 | - assert.strictEqual(output.status, 0); | ||
| 36 | 32 | const profiles = getHeapProfiles(tmpdir.path); | |
| 37 | 33 | assert.strictEqual(profiles.length, 1); | |
| 38 | 34 | verifyFrames(output, profiles[0], 'runAllocation'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ const fixtures = require('../common/fixtures'); | |||
| 8 | 8 | common.skipIfInspectorDisabled(); | |
| 9 | 9 | ||
| 10 | 10 | const assert = require('assert'); | |
| 11 | - const { spawnSync } = require('child_process'); | ||
| 11 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 12 | 12 | ||
| 13 | 13 | const tmpdir = require('../common/tmpdir'); | |
| 14 | 14 | ||
@@ -21,7 +21,7 @@ const { | |||
| 21 | 21 | ||
| 22 | 22 | { | |
| 23 | 23 | tmpdir.refresh(); | |
| 24 | - const output = spawnSync(process.execPath, [ | ||
| 24 | + const { child: output } = spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 25 | 25 | '--heap-prof', | |
| 26 | 26 | '--heap-prof-interval', | |
| 27 | 27 | kHeapProfInterval, | |
@@ -30,11 +30,6 @@ const { | |||
| 30 | 30 | cwd: tmpdir.path, | |
| 31 | 31 | env | |
| 32 | 32 | }); | |
| 33 | - if (output.status !== 0) { | ||
| 34 | - console.log(output.stderr.toString()); | ||
| 35 | - console.log(output); | ||
| 36 | - } | ||
| 37 | - assert.strictEqual(output.status, 0); | ||
| 38 | 33 | const profiles = getHeapProfiles(tmpdir.path); | |
| 39 | 34 | assert.strictEqual(profiles.length, 1); | |
| 40 | 35 | verifyFrames(output, profiles[0], 'runAllocation'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | common.skipIfInspectorDisabled(); | |
| 4 | 4 | ||
| 5 | - const { spawnSync } = require('child_process'); | ||
| 5 | + const { spawnSyncAndExit } = require('../common/child_process'); | ||
| 6 | 6 | const { createServer } = require('http'); | |
| 7 | 7 | const assert = require('assert'); | |
| 8 | 8 | const tmpdir = require('../common/tmpdir'); | |
@@ -25,19 +25,18 @@ function testOnServerListen(fn) { | |||
| 25 | 25 | function testChildProcess(getArgs, exitCode, options) { | |
| 26 | 26 | testOnServerListen(common.mustCall((server) => { | |
| 27 | 27 | const { port } = server.address(); | |
| 28 | - const child = spawnSync(process.execPath, getArgs(port), options); | ||
| 29 | - const stderr = child.stderr.toString().trim(); | ||
| 30 | - const stdout = child.stdout.toString().trim(); | ||
| 31 | - console.log('[STDERR]'); | ||
| 32 | - console.log(stderr); | ||
| 33 | - console.log('[STDOUT]'); | ||
| 34 | - console.log(stdout); | ||
| 35 | - const match = stderr.match( | ||
| 36 | - /Starting inspector on 127\.0\.0\.1:(\d+) failed: address already in use/ | ||
| 37 | - ); | ||
| 38 | - assert.notStrictEqual(match, null); | ||
| 39 | - assert.strictEqual(match[1], port + ''); | ||
| 40 | - assert.strictEqual(child.status, exitCode); | ||
| 28 | + spawnSyncAndExit(process.execPath, getArgs(port), options, { | ||
| 29 | + status: exitCode, | ||
| 30 | + signal: null, | ||
| 31 | + trim: true, | ||
| 32 | + stderr: function(str) { | ||
| 33 | + const match = str.match( | ||
| 34 | + /Starting inspector on 127\.0\.0\.1:(\d+) failed: address already in use/ | ||
| 35 | + ); | ||
| 36 | + assert.notStrictEqual(match, null); | ||
| 37 | + assert.strictEqual(match[1], port + ''); | ||
| 38 | + }, | ||
| 39 | + }); | ||
| 41 | 40 | })); | |
| 42 | 41 | } | |
| 43 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,9 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | const assert = require('assert'); | |
| 4 | - const cp = require('child_process'); | ||
| 5 | 4 | const os = require('os'); | |
| 6 | 5 | const path = require('path'); | |
| 6 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | 9 | if (process.argv[2] === 'child') { | |
@@ -22,9 +22,7 @@ if (process.argv[2] === 'child') { | |||
| 22 | 22 | else | |
| 23 | 23 | delete process.env.HOME; | |
| 24 | 24 | ||
| 25 | - const child = cp.spawnSync(process.execPath, [__filename, 'child'], { | ||
| 25 | + spawnSyncAndExitWithoutError(process.execPath, [__filename, 'child'], { | ||
| 26 | 26 | env: process.env | |
| 27 | 27 | }); | |
| 28 | - | ||
| 29 | - assert.strictEqual(child.status, 0); | ||
| 30 | 28 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ if (common.isWindows) | |||
| 4 | 4 | common.skip('symlinks are weird on windows'); | |
| 5 | 5 | ||
| 6 | 6 | const assert = require('assert'); | |
| 7 | - const child_process = require('child_process'); | ||
| 7 | + const { spawnSyncAndAssert } = require('../common/child_process'); | ||
| 8 | 8 | const fs = require('fs'); | |
| 9 | 9 | ||
| 10 | 10 | assert.strictEqual(process.execPath, fs.realpathSync(process.execPath)); | |
@@ -19,8 +19,8 @@ if (process.argv[2] === 'child') { | |||
| 19 | 19 | const symlinkedNode = tmpdir.resolve('symlinked-node'); | |
| 20 | 20 | fs.symlinkSync(process.execPath, symlinkedNode); | |
| 21 | 21 | ||
| 22 | - const proc = child_process.spawnSync(symlinkedNode, [__filename, 'child']); | ||
| 23 | - assert.strictEqual(proc.stderr.toString(), ''); | ||
| 24 | - assert.strictEqual(proc.stdout.toString(), `${process.execPath}\n`); | ||
| 25 | - assert.strictEqual(proc.status, 0); | ||
| 22 | + spawnSyncAndAssert(symlinkedNode, [__filename, 'child'], { | ||
| 23 | + stdout: `${process.execPath}\n`, | ||
| 24 | + stderr: '' | ||
| 25 | + }); | ||
| 26 | 26 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | require('../common'); | |
| 3 | 3 | const fixtures = require('../common/fixtures'); | |
| 4 | - const assert = require('node:assert'); | ||
| 5 | - const { spawnSync } = require('node:child_process'); | ||
| 4 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 6 | 5 | const { test } = require('node:test'); | |
| 7 | 6 | ||
| 8 | 7 | test('mock timers do not break test timeout cleanup', async () => { | |
| 9 | 8 | const fixture = fixtures.path('test-runner', 'mock-timers-with-timeout.js'); | |
| 10 | - const cp = spawnSync(process.execPath, ['--test', fixture], { | ||
| 9 | + spawnSyncAndExitWithoutError(process.execPath, ['--test', fixture], { | ||
| 11 | 10 | timeout: 30_000, | |
| 12 | 11 | }); | |
| 13 | - assert.strictEqual(cp.status, 0, `Test failed:\nstdout: ${cp.stdout}\nstderr: ${cp.stderr}`); | ||
| 14 | 12 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,15 +5,15 @@ const fixtures = require('../common/fixtures'); | |||
| 5 | 5 | const tmpdir = require('../common/tmpdir'); | |
| 6 | 6 | const assert = require('assert'); | |
| 7 | 7 | const fs = require('fs'); | |
| 8 | - const { spawnSync } = require('child_process'); | ||
| 8 | + const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| 9 | 9 | ||
| 10 | 10 | common.skipIfInspectorDisabled(); | |
| 11 | 11 | ||
| 12 | 12 | tmpdir.refresh(); | |
| 13 | 13 | const intervals = 20; | |
| 14 | 14 | ||
| 15 | 15 | { | |
| 16 | - const output = spawnSync(process.execPath, [ | ||
| 16 | + const { child } = spawnSyncAndExitWithoutError(process.execPath, [ | ||
| 17 | 17 | '-r', | |
| 18 | 18 | fixtures.path('v8-coverage', 'stop-coverage'), | |
| 19 | 19 | '-r', | |
@@ -27,8 +27,7 @@ const intervals = 20; | |||
| 27 | 27 | TEST_INTERVALS: intervals | |
| 28 | 28 | }, | |
| 29 | 29 | }); | |
| 30 | - console.log(output.stderr.toString()); | ||
| 31 | - assert.strictEqual(output.status, 0); | ||
| 30 | + console.log(child.stderr.toString()); | ||
| 32 | 31 | const coverageFiles = fs.readdirSync(tmpdir.path); | |
| 33 | 32 | assert.strictEqual(coverageFiles.length, 0); | |
| 34 | 33 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments