node/test/sea/test-single-executable-application-asset-keys-empty.js
Joyee Cheung 64bbb979de
test: move sea tests into test/sea
This makes skipping/running these tests easier to manage with a
dedicated test runner that can be tweaked for SEA.

PR-URL: https://github.com/nodejs/node/pull/60250
Refs: https://github.com/nodejs/node/issues/59553
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2025-10-17 12:51:59 +02:00

66 lines
1.4 KiB
JavaScript

'use strict';
// This test verifies that the `getAssetKeys()` function works correctly
// in a single executable application without any assets.
require('../common');
const {
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');
skipIfSingleExecutableIsNotSupported();
const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs');
const {
spawnSyncAndExitWithoutError,
spawnSyncAndAssert,
} = require('../common/child_process');
const assert = require('assert');
const fixtures = require('../common/fixtures');
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
tmpdir.refresh();
copyFileSync(fixtures.path('sea', 'get-asset-keys.js'), tmpdir.resolve('sea.js'));
writeFileSync(tmpdir.resolve('sea-config.json'), `
{
"main": "sea.js",
"output": "sea-prep.blob"
}
`, 'utf8');
spawnSyncAndExitWithoutError(
process.execPath,
['--experimental-sea-config', 'sea-config.json'],
{
env: {
NODE_DEBUG_NATIVE: 'SEA',
...process.env,
},
cwd: tmpdir.path,
},
{});
assert(existsSync(seaPrepBlob));
generateSEA(outputFile, process.execPath, seaPrepBlob);
spawnSyncAndAssert(
outputFile,
{
env: {
...process.env,
NODE_DEBUG_NATIVE: 'SEA',
},
},
{
stdout: /Asset keys: \[\]/,
},
);