node/test/sea/test-single-executable-application-snapshot.js
Joyee Cheung 6eaf1b85ed
test: migrate to --build-sea in existing SEA tests
Only leave a smoking test for the postject-based workflow
in test-single-executable-application.js

PR-URL: https://github.com/nodejs/node/pull/61167
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-22 23:32:51 +01:00

71 lines
1.4 KiB
JavaScript

'use strict';
require('../common');
const {
buildSEA,
skipIfBuildSEAIsNotSupported,
} = require('../common/sea');
skipIfBuildSEAIsNotSupported();
// This tests the snapshot support in single executable applications.
const tmpdir = require('../common/tmpdir');
const { writeFileSync } = require('fs');
const {
spawnSyncAndAssert,
spawnSyncAndExit,
} = require('../common/child_process');
const fixtures = require('../common/fixtures');
const assert = require('assert');
{
tmpdir.refresh();
writeFileSync(tmpdir.resolve('snapshot.js'), '', 'utf-8');
writeFileSync(tmpdir.resolve('sea-config.json'), `
{
"main": "snapshot.js",
"output": "sea-prep.blob",
"useSnapshot": true
}
`);
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\(\)/,
});
}
{
tmpdir.refresh();
const outputFile = buildSEA(fixtures.path('sea', 'snapshot'));
spawnSyncAndAssert(
outputFile,
{
env: {
NODE_DEBUG_NATIVE: 'SEA,MKSNAPSHOT',
...process.env,
},
},
{
trim: true,
stdout: 'Hello from snapshot',
stderr(output) {
assert.doesNotMatch(
output,
/Single executable application is an experimental feature/);
},
},
);
}