test: add spawnSyncAndAssert util

PR-URL: https://github.com/nodejs/node/pull/52132
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
Antoine du Hamel 2024-03-20 20:44:14 +02:00 committed by GitHub
parent f69946b905
commit c714cda9a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 77 additions and 72 deletions

View File

@ -70,11 +70,15 @@ gathering more information about test failures coming from child processes.
* `stderr` [\<string>][<string>] The output from the child process to stderr. * `stderr` [\<string>][<string>] The output from the child process to stderr.
* `stdout` [\<string>][<string>] The output from the child process to stdout. * `stdout` [\<string>][<string>] The output from the child process to stdout.
### `spawnSyncAndExitWithoutError(command[, args][, spawnOptions], expectations)` ### `spawnSyncAndExitWithoutError(command[, args][, spawnOptions])`
Similar to `expectSyncExit()` with the `status` expected to be 0 and Similar to `expectSyncExit()` with the `status` expected to be 0 and
`signal` expected to be `null`. Any other optional options are passed `signal` expected to be `null`.
into `expectSyncExit()`.
### `spawnSyncAndAssert(command[, args][, spawnOptions], expectations)`
Similar to `spawnSyncAndExitWithoutError()`, but with an additional
`expectations` parameter.
## Common Module API ## Common Module API

View File

@ -119,9 +119,15 @@ function spawnSyncAndExit(...args) {
} }
function spawnSyncAndExitWithoutError(...args) { function spawnSyncAndExitWithoutError(...args) {
const spawnArgs = args.slice(0, args.length); return expectSyncExit(spawnSync(...args), {
const expectations = args[args.length - 1]; status: 0,
const child = spawnSync(...spawnArgs); signal: null,
});
}
function spawnSyncAndAssert(...args) {
const expectations = args.pop();
const child = spawnSync(...args);
return expectSyncExit(child, { return expectSyncExit(child, {
status: 0, status: 0,
signal: null, signal: null,
@ -134,6 +140,7 @@ module.exports = {
logAfterTime, logAfterTime,
kExpiringChildRunTime, kExpiringChildRunTime,
kExpiringParentTimer, kExpiringParentTimer,
spawnSyncAndAssert,
spawnSyncAndExit, spawnSyncAndExit,
spawnSyncAndExitWithoutError, spawnSyncAndExitWithoutError,
}; };

View File

@ -92,8 +92,8 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
try { try {
spawnSyncAndExitWithoutError('codesign', [ '--sign', '-', targetExecutable ], {}); spawnSyncAndExitWithoutError('codesign', [ '--sign', '-', targetExecutable ]);
spawnSyncAndExitWithoutError('codesign', [ '--verify', targetExecutable ], {}); spawnSyncAndExitWithoutError('codesign', [ '--verify', targetExecutable ]);
} catch (e) { } catch (e) {
const message = `Cannot sign ${targetExecutable}: ${inspect(e)}`; const message = `Cannot sign ${targetExecutable}: ${inspect(e)}`;
if (verifyWorkflow) { if (verifyWorkflow) {
@ -104,7 +104,7 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow
console.log(`Signed ${targetExecutable}`); console.log(`Signed ${targetExecutable}`);
} else if (process.platform === 'win32') { } else if (process.platform === 'win32') {
try { try {
spawnSyncAndExitWithoutError('where', [ 'signtool' ], {}); spawnSyncAndExitWithoutError('where', [ 'signtool' ]);
} catch (e) { } catch (e) {
const message = `Cannot find signtool: ${inspect(e)}`; const message = `Cannot find signtool: ${inspect(e)}`;
if (verifyWorkflow) { if (verifyWorkflow) {
@ -114,8 +114,8 @@ function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow
} }
let stderr; let stderr;
try { try {
({ stderr } = spawnSyncAndExitWithoutError('signtool', [ 'sign', '/fd', 'SHA256', targetExecutable ], {})); ({ stderr } = spawnSyncAndExitWithoutError('signtool', [ 'sign', '/fd', 'SHA256', targetExecutable ]));
spawnSyncAndExitWithoutError('signtool', 'verify', '/pa', 'SHA256', targetExecutable, {}); spawnSyncAndExitWithoutError('signtool', ['verify', '/pa', 'SHA256', targetExecutable]);
} catch (e) { } catch (e) {
const message = `Cannot sign ${targetExecutable}: ${inspect(e)}\n${stderr}`; const message = `Cannot sign ${targetExecutable}: ${inspect(e)}\n${stderr}`;
if (verifyWorkflow) { if (verifyWorkflow) {

View File

@ -1,7 +1,7 @@
// Test version set to preview1 // Test version set to preview1
'use strict'; 'use strict';
const { spawnSyncAndExitWithoutError } = require('./child_process'); const { spawnSyncAndAssert } = require('./child_process');
const fixtures = require('./fixtures'); const fixtures = require('./fixtures');
const childPath = fixtures.path('wasi-preview-1.js'); const childPath = fixtures.path('wasi-preview-1.js');
@ -15,7 +15,7 @@ function testWasiPreview1(args, spawnArgs = {}, expectations = {}) {
spawnArgs.env = newEnv; spawnArgs.env = newEnv;
console.log('Testing with --turbo-fast-api-calls:', ...args); console.log('Testing with --turbo-fast-api-calls:', ...args);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
process.execPath, [ process.execPath, [
'--turbo-fast-api-calls', '--turbo-fast-api-calls',
childPath, childPath,
@ -26,7 +26,7 @@ function testWasiPreview1(args, spawnArgs = {}, expectations = {}) {
); );
console.log('Testing with --no-turbo-fast-api-calls:', ...args); console.log('Testing with --no-turbo-fast-api-calls:', ...args);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
process.execPath, process.execPath,
[ [
'--no-turbo-fast-api-calls', '--no-turbo-fast-api-calls',

View File

@ -4,6 +4,7 @@ const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const assert = require('assert'); const assert = require('assert');
const { const {
spawnSyncAndAssert,
spawnSyncAndExit, spawnSyncAndExit,
spawnSyncAndExitWithoutError, spawnSyncAndExitWithoutError,
} = require('../common/child_process'); } = require('../common/child_process');
@ -23,7 +24,7 @@ function resolveBuiltBinary(binary) {
const binary = resolveBuiltBinary('embedtest'); const binary = resolveBuiltBinary('embedtest');
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
binary, binary,
['console.log(42)'], ['console.log(42)'],
{ {
@ -31,7 +32,7 @@ spawnSyncAndExitWithoutError(
stdout: '42', stdout: '42',
}); });
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
binary, binary,
['console.log(embedVars.nön_ascıı)'], ['console.log(embedVars.nön_ascıı)'],
{ {
@ -111,9 +112,8 @@ for (const extraSnapshotArgs of [
spawnSyncAndExitWithoutError( spawnSyncAndExitWithoutError(
binary, binary,
[ '--', ...buildSnapshotArgs ], [ '--', ...buildSnapshotArgs ],
{ cwd: tmpdir.path }, { cwd: tmpdir.path });
{}); spawnSyncAndAssert(
spawnSyncAndExitWithoutError(
binary, binary,
[ '--', ...runSnapshotArgs ], [ '--', ...runSnapshotArgs ],
{ cwd: tmpdir.path }, { cwd: tmpdir.path },
@ -145,11 +145,9 @@ for (const extraSnapshotArgs of [
spawnSyncAndExitWithoutError( spawnSyncAndExitWithoutError(
binary, binary,
[ '--', ...buildSnapshotArgs ], [ '--', ...buildSnapshotArgs ],
{ cwd: tmpdir.path }, { cwd: tmpdir.path });
{});
spawnSyncAndExitWithoutError( spawnSyncAndExitWithoutError(
binary, binary,
[ '--', ...runEmbeddedArgs ], [ '--', ...runEmbeddedArgs ],
{ cwd: tmpdir.path }, { cwd: tmpdir.path });
{});
} }

View File

@ -26,6 +26,5 @@ if (process.argv[2] !== 'child') {
// enabled. // enabled.
spawnSyncAndExitWithoutError( spawnSyncAndExitWithoutError(
process.execPath, process.execPath,
['--enable-source-maps', __filename, 'child'], ['--enable-source-maps', __filename, 'child']);
{});
} }

View File

@ -6,7 +6,7 @@ require('../common');
const assert = require('assert'); const assert = require('assert');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
const fs = require('fs'); const fs = require('fs');
const v8 = require('v8'); const v8 = require('v8');
@ -41,7 +41,7 @@ const entry = fixtures.path('snapshot', 'v8-startup-snapshot-api.js');
} }
{ {
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
'book1', 'book1',

View File

@ -8,8 +8,9 @@ const assert = require('assert');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
const { const {
spawnSyncAndExitWithoutError, spawnSyncAndAssert,
spawnSyncAndExit, spawnSyncAndExit,
spawnSyncAndExitWithoutError,
} = require('../common/child_process'); } = require('../common/child_process');
const fs = require('fs'); const fs = require('fs');
@ -65,7 +66,7 @@ const blobPath = tmpdir.resolve('my-snapshot.blob');
{ {
// Check --help. // Check --help.
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
'--help', '--help',
@ -78,7 +79,7 @@ const blobPath = tmpdir.resolve('my-snapshot.blob');
{ {
// Check -c. // Check -c.
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
'-c', '-c',

View File

@ -4,7 +4,7 @@
// restoring state from a snapshot // restoring state from a snapshot
require('../common'); require('../common');
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const { spawnSyncAndAssert } = require('../common/child_process');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
const assert = require('assert'); const assert = require('assert');
@ -20,7 +20,7 @@ const expected = [
{ {
// Create the snapshot. // Create the snapshot.
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
'--build-snapshot', '--build-snapshot',
@ -37,7 +37,7 @@ const expected = [
} }
{ {
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
file, file,

View File

@ -5,8 +5,9 @@
require('../common'); require('../common');
const assert = require('assert'); const assert = require('assert');
const { const {
spawnSyncAndExitWithoutError, spawnSyncAndAssert,
spawnSyncAndExit, spawnSyncAndExit,
spawnSyncAndExitWithoutError,
} = require('../common/child_process'); } = require('../common/child_process');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
@ -84,7 +85,7 @@ let sizeWithCache;
configPath, configPath,
], { ], {
cwd: tmpdir.path cwd: tmpdir.path
}, {}); });
const stats = fs.statSync(blobPath); const stats = fs.statSync(blobPath);
assert(stats.isFile()); assert(stats.isFile());
sizeWithCache = stats.size; sizeWithCache = stats.size;
@ -115,14 +116,14 @@ let sizeWithoutCache;
NODE_DEBUG_NATIVE: 'CODE_CACHE' NODE_DEBUG_NATIVE: 'CODE_CACHE'
}, },
cwd: tmpdir.path cwd: tmpdir.path
}, {}); });
const stats = fs.statSync(blobPath); const stats = fs.statSync(blobPath);
assert(stats.isFile()); assert(stats.isFile());
sizeWithoutCache = stats.size; sizeWithoutCache = stats.size;
assert(sizeWithoutCache < sizeWithCache, assert(sizeWithoutCache < sizeWithCache,
`sizeWithoutCache = ${sizeWithoutCache} >= sizeWithCache ${sizeWithCache}`); `sizeWithoutCache = ${sizeWithoutCache} >= sizeWithCache ${sizeWithCache}`);
// Check the snapshot. // Check the snapshot.
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
checkFile, checkFile,

View File

@ -4,7 +4,7 @@
// restoring state from a snapshot // restoring state from a snapshot
require('../common'); require('../common');
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const { spawnSyncAndAssert } = require('../common/child_process');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
const fs = require('fs'); const fs = require('fs');
@ -18,7 +18,7 @@ fs.mkdirSync(subdir);
{ {
// Create the snapshot. // Create the snapshot.
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
'--build-snapshot', '--build-snapshot',
@ -32,7 +32,7 @@ fs.mkdirSync(subdir);
} }
{ {
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
file, file,

View File

@ -9,7 +9,7 @@ require('../common');
const assert = require('assert'); const assert = require('assert');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
const fs = require('fs'); const fs = require('fs');
const warningScript = fixtures.path('snapshot', 'warning.js'); const warningScript = fixtures.path('snapshot', 'warning.js');
@ -30,7 +30,7 @@ tmpdir.refresh();
const stats = fs.statSync(blobPath); const stats = fs.statSync(blobPath);
assert(stats.isFile()); assert(stats.isFile());
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
warningScript, warningScript,
@ -49,7 +49,7 @@ tmpdir.refresh();
{ {
console.log('\n# Check snapshot scripts that emit ' + console.log('\n# Check snapshot scripts that emit ' +
'warnings and --trace-warnings hint.'); 'warnings and --trace-warnings hint.');
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
'--build-snapshot', '--build-snapshot',
@ -68,7 +68,7 @@ tmpdir.refresh();
const stats = fs.statSync(blobPath); const stats = fs.statSync(blobPath);
assert(stats.isFile()); assert(stats.isFile());
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
warningScript, warningScript,
@ -92,7 +92,7 @@ tmpdir.refresh();
const warningFile1 = tmpdir.resolve('warnings.txt'); const warningFile1 = tmpdir.resolve('warnings.txt');
const warningFile2 = tmpdir.resolve('warnings2.txt'); const warningFile2 = tmpdir.resolve('warnings2.txt');
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
'--redirect-warnings', '--redirect-warnings',
@ -120,7 +120,7 @@ tmpdir.refresh();
maxRetries: 3, recursive: false, force: true maxRetries: 3, recursive: false, force: true
}); });
spawnSyncAndExitWithoutError(process.execPath, [ spawnSyncAndAssert(process.execPath, [
'--snapshot-blob', '--snapshot-blob',
blobPath, blobPath,
'--redirect-warnings', '--redirect-warnings',

View File

@ -51,8 +51,7 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
...process.env, ...process.env,
}, },
cwd: tmpdir.path cwd: tmpdir.path
}, });
{});
assert(existsSync(seaPrepBlob)); assert(existsSync(seaPrepBlob));
@ -67,6 +66,5 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
__TEST_PERSON_JPG: fixtures.path('person.jpg'), __TEST_PERSON_JPG: fixtures.path('person.jpg'),
} }
}, },
{ }
); );
} }

View File

@ -14,6 +14,7 @@ const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs'); const { copyFileSync, writeFileSync, existsSync } = require('fs');
const { const {
spawnSyncAndAssert,
spawnSyncAndExit, spawnSyncAndExit,
spawnSyncAndExitWithoutError, spawnSyncAndExitWithoutError,
} = require('../common/child_process'); } = require('../common/child_process');
@ -104,14 +105,13 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
...process.env, ...process.env,
}, },
cwd: tmpdir.path cwd: tmpdir.path
}, });
{});
assert(existsSync(seaPrepBlob)); assert(existsSync(seaPrepBlob));
generateSEA(outputFile, process.execPath, seaPrepBlob); generateSEA(outputFile, process.execPath, seaPrepBlob);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
outputFile, outputFile,
{ {
env: { env: {

View File

@ -15,7 +15,7 @@ skipIfSingleExecutableIsNotSupported();
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs'); const { copyFileSync, writeFileSync, existsSync } = require('fs');
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
const { join } = require('path'); const { join } = require('path');
const assert = require('assert'); const assert = require('assert');
@ -46,14 +46,13 @@ copyFileSync(inputFile, tmpdir.resolve('sea.js'));
spawnSyncAndExitWithoutError( spawnSyncAndExitWithoutError(
process.execPath, process.execPath,
['--experimental-sea-config', 'sea-config.json'], ['--experimental-sea-config', 'sea-config.json'],
{ cwd: tmpdir.path }, { cwd: tmpdir.path });
{});
assert(existsSync(seaPrepBlob)); assert(existsSync(seaPrepBlob));
generateSEA(outputFile, process.execPath, seaPrepBlob); generateSEA(outputFile, process.execPath, seaPrepBlob);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
outputFile, outputFile,
[ '-a', '--b=c', 'd' ], [ '-a', '--b=c', 'd' ],
{ {

View File

@ -60,5 +60,4 @@ spawnSyncAndExitWithoutError(
NODE_DEBUG_NATIVE: 'SEA', NODE_DEBUG_NATIVE: 'SEA',
...process.env, ...process.env,
} }
}, });
{});

View File

@ -14,7 +14,7 @@ skipIfSingleExecutableIsNotSupported();
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const { writeFileSync, existsSync } = require('fs'); const { writeFileSync, existsSync } = require('fs');
const { const {
spawnSyncAndExitWithoutError spawnSyncAndAssert,
} = require('../common/child_process'); } = require('../common/child_process');
const { join } = require('path'); const { join } = require('path');
const assert = require('assert'); const assert = require('assert');
@ -45,7 +45,7 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' :
} }
`); `);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
process.execPath, process.execPath,
['--experimental-sea-config', 'sea-config.json'], ['--experimental-sea-config', 'sea-config.json'],
{ {
@ -64,7 +64,7 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' :
generateSEA(outputFile, process.execPath, seaPrepBlob); generateSEA(outputFile, process.execPath, seaPrepBlob);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
outputFile, outputFile,
{ {
env: { env: {

View File

@ -14,8 +14,8 @@ skipIfSingleExecutableIsNotSupported();
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const { writeFileSync, existsSync } = require('fs'); const { writeFileSync, existsSync } = require('fs');
const { const {
spawnSyncAndAssert,
spawnSyncAndExit, spawnSyncAndExit,
spawnSyncAndExitWithoutError
} = require('../common/child_process'); } = require('../common/child_process');
const assert = require('assert'); const assert = require('assert');
@ -69,7 +69,7 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
} }
`); `);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
process.execPath, process.execPath,
['--experimental-sea-config', 'sea-config.json'], ['--experimental-sea-config', 'sea-config.json'],
{ {
@ -87,7 +87,7 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
generateSEA(outputFile, process.execPath, seaPrepBlob); generateSEA(outputFile, process.execPath, seaPrepBlob);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
outputFile, outputFile,
{ {
env: { env: {

View File

@ -15,7 +15,7 @@ skipIfSingleExecutableIsNotSupported();
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs'); const { copyFileSync, writeFileSync, existsSync } = require('fs');
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
const { join } = require('path'); const { join } = require('path');
const assert = require('assert'); const assert = require('assert');
@ -58,7 +58,7 @@ assert(existsSync(seaPrepBlob));
generateSEA(outputFile, process.execPath, seaPrepBlob); generateSEA(outputFile, process.execPath, seaPrepBlob);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
outputFile, outputFile,
[ '-a', '--b=c', 'd' ], [ '-a', '--b=c', 'd' ],
{ {

View File

@ -14,7 +14,7 @@ skipIfSingleExecutableIsNotSupported();
const fixtures = require('../common/fixtures'); const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs'); const { copyFileSync, writeFileSync, existsSync } = require('fs');
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
const { join } = require('path'); const { join } = require('path');
const assert = require('assert'); const assert = require('assert');
@ -45,14 +45,13 @@ copyFileSync(inputFile, tmpdir.resolve('sea.js'));
spawnSyncAndExitWithoutError( spawnSyncAndExitWithoutError(
process.execPath, process.execPath,
['--experimental-sea-config', 'sea-config.json'], ['--experimental-sea-config', 'sea-config.json'],
{ cwd: tmpdir.path }, { cwd: tmpdir.path });
{});
assert(existsSync(seaPrepBlob)); assert(existsSync(seaPrepBlob));
generateSEA(outputFile, process.execPath, seaPrepBlob); generateSEA(outputFile, process.execPath, seaPrepBlob);
spawnSyncAndExitWithoutError( spawnSyncAndAssert(
outputFile, outputFile,
[ '-a', '--b=c', 'd' ], [ '-a', '--b=c', 'd' ],
{ {

View File

@ -3,7 +3,7 @@ const common = require('../common');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const fs = require('fs'); const fs = require('fs');
const assert = require('assert'); const assert = require('assert');
const { spawnSyncAndExitWithoutError } = require('../common/child_process'); const { spawnSyncAndAssert } = require('../common/child_process');
// Test that --prof also tracks Worker threads. // Test that --prof also tracks Worker threads.
// Refs: https://github.com/nodejs/node/issues/24016 // Refs: https://github.com/nodejs/node/issues/24016
@ -50,7 +50,7 @@ if (process.argv[2] === 'child') {
const workerProfRegexp = /worker prof file: (.+\.log)/; const workerProfRegexp = /worker prof file: (.+\.log)/;
const parentProfRegexp = /parent prof file: (.+\.log)/; const parentProfRegexp = /parent prof file: (.+\.log)/;
const { stdout } = spawnSyncAndExitWithoutError( const { stdout } = spawnSyncAndAssert(
process.execPath, ['--prof', __filename, 'child'], process.execPath, ['--prof', __filename, 'child'],
{ cwd: tmpdir.path, encoding: 'utf8' }, { { cwd: tmpdir.path, encoding: 'utf8' }, {
stdout(output) { stdout(output) {