test: use spawnSyncAndExitWithoutError in sea tests
To display more information when the command fails. PR-URL: https://github.com/nodejs/node/pull/49543 Refs: https://github.com/nodejs/reliability/issues/658 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
parent
31657f73f1
commit
65d396b0a0
@ -13,7 +13,9 @@ skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSync } = require('child_process');
|
||||
const {
|
||||
spawnSyncAndExitWithoutError
|
||||
} = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
@ -43,21 +45,24 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' :
|
||||
}
|
||||
`);
|
||||
|
||||
let child = spawnSync(
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path
|
||||
});
|
||||
assert.match(
|
||||
child.stderr.toString(),
|
||||
/"useCodeCache" is redundant when "useSnapshot" is true/);
|
||||
},
|
||||
{
|
||||
stderr: /"useCodeCache" is redundant when "useSnapshot" is true/
|
||||
}
|
||||
);
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
copyFileSync(process.execPath, outputFile);
|
||||
injectAndCodeSign(outputFile, seaPrepBlob);
|
||||
|
||||
child = spawnSync(outputFile);
|
||||
assert.strictEqual(child.stdout.toString().trim(), 'Hello from snapshot');
|
||||
spawnSyncAndExitWithoutError(outputFile, {
|
||||
stdout: 'Hello from snapshot',
|
||||
trim: true,
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSync } = require('child_process');
|
||||
const {
|
||||
spawnSyncAndExit,
|
||||
spawnSyncAndExitWithoutError
|
||||
} = require('../common/child_process');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
@ -32,16 +35,17 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
|
||||
}
|
||||
`);
|
||||
|
||||
const child = spawnSync(
|
||||
spawnSyncAndExit(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path
|
||||
},
|
||||
{
|
||||
status: 1,
|
||||
signal: null,
|
||||
stderr: /snapshot\.js does not invoke v8\.startupSnapshot\.setDeserializeMainFunction\(\)/
|
||||
});
|
||||
|
||||
assert.match(
|
||||
child.stderr.toString(),
|
||||
/snapshot\.js does not invoke v8\.startupSnapshot\.setDeserializeMainFunction\(\)/);
|
||||
}
|
||||
|
||||
{
|
||||
@ -65,24 +69,31 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
|
||||
}
|
||||
`);
|
||||
|
||||
let child = spawnSync(
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path
|
||||
},
|
||||
{
|
||||
stderr: /Single executable application is an experimental feature/
|
||||
});
|
||||
assert.match(
|
||||
child.stderr.toString(),
|
||||
/Single executable application is an experimental feature/);
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
copyFileSync(process.execPath, outputFile);
|
||||
injectAndCodeSign(outputFile, seaPrepBlob);
|
||||
|
||||
child = spawnSync(outputFile);
|
||||
assert.strictEqual(child.stdout.toString().trim(), 'Hello from snapshot');
|
||||
assert.doesNotMatch(
|
||||
child.stderr.toString(),
|
||||
/Single executable application is an experimental feature/);
|
||||
spawnSyncAndExitWithoutError(
|
||||
outputFile,
|
||||
{
|
||||
trim: true,
|
||||
stdout: 'Hello from snapshot',
|
||||
stderr(output) {
|
||||
assert.doesNotMatch(
|
||||
output,
|
||||
/Single executable application is an experimental feature/);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user