mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
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>
75 lines
1.8 KiB
JavaScript
75 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
// This test verifies that the `getAssetKeys()` function works correctly
|
|
// in a single executable application with 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 configFile = tmpdir.resolve('sea-config.json');
|
|
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('asset-1.txt'), 'This is asset 1');
|
|
writeFileSync(tmpdir.resolve('asset-2.txt'), 'This is asset 2');
|
|
writeFileSync(tmpdir.resolve('asset-3.txt'), 'This is asset 3');
|
|
|
|
writeFileSync(configFile, `
|
|
{
|
|
"main": "sea.js",
|
|
"output": "sea-prep.blob",
|
|
"assets": {
|
|
"asset-1.txt": "asset-1.txt",
|
|
"asset-2.txt": "asset-2.txt",
|
|
"asset-3.txt": "asset-3.txt"
|
|
}
|
|
}
|
|
`, '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: \["asset-1\.txt","asset-2\.txt","asset-3\.txt"\]/,
|
|
},
|
|
);
|