mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
test: use fixture directories for sea tests
Instead of copying and writing files on the fly for SEA tests, put the fixtures into a directory and copy them into tmpdir for testing. This allows easier reproduction and debugging when they do fail - we can just copy the entire fixture directory and test directly from there. PR-URL: https://github.com/nodejs/node/pull/61167 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
73 files changed
+651
-729
No files matched your search
+50
-8
@@ -4,6 +4,9 @@ const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { inspect } = require('util');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const { readFileSync, copyFileSync, statSync } = require('fs');
|
||||
const {
|
||||
@@ -70,37 +73,76 @@ function skipIfSingleExecutableIsNotSupported() {
|
||||
}
|
||||
}
|
||||
|
||||
function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow = false) {
|
||||
function generateSEA(fixtureDir, options = {}) {
|
||||
const {
|
||||
workingDir = tmpdir.path,
|
||||
configPath = 'sea-config.json',
|
||||
verifyWorkflow = false,
|
||||
} = options;
|
||||
// Copy fixture files to working directory if they are different.
|
||||
if (fixtureDir !== workingDir) {
|
||||
fs.cpSync(fixtureDir, workingDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Determine the output executable path.
|
||||
const outputFile = path.resolve(workingDir, process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
|
||||
try {
|
||||
copyFileSync(sourceExecutable, targetExecutable);
|
||||
// Copy the executable.
|
||||
copyFileSync(process.execPath, outputFile);
|
||||
console.log(`Copied ${process.execPath} to ${outputFile}`);
|
||||
} catch (e) {
|
||||
const message = `Cannot copy ${sourceExecutable} to ${targetExecutable}: ${inspect(e)}`;
|
||||
const message = `Cannot copy ${process.execPath} to ${outputFile}: ${inspect(e)}`;
|
||||
if (verifyWorkflow) {
|
||||
throw new Error(message);
|
||||
}
|
||||
common.skip(message);
|
||||
}
|
||||
console.log(`Copied ${sourceExecutable} to ${targetExecutable}`);
|
||||
|
||||
// Generate the blob using --experimental-sea-config.
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', configPath],
|
||||
{
|
||||
cwd: workingDir,
|
||||
env: {
|
||||
NODE_DEBUG_NATIVE: 'SEA',
|
||||
...process.env,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Parse the config to get the output file path.
|
||||
const config = JSON.parse(fs.readFileSync(path.resolve(workingDir, configPath)));
|
||||
assert.strictEqual(typeof config.output, 'string');
|
||||
const seaPrepBlob = path.resolve(workingDir, config.output);
|
||||
assert(fs.existsSync(seaPrepBlob), `Expected SEA blob ${seaPrepBlob} to exist`);
|
||||
|
||||
// Use postject to inject the blob.
|
||||
const postjectFile = fixtures.path('postject-copy', 'node_modules', 'postject', 'dist', 'cli.js');
|
||||
try {
|
||||
spawnSyncAndExitWithoutError(process.execPath, [
|
||||
postjectFile,
|
||||
targetExecutable,
|
||||
outputFile,
|
||||
'NODE_SEA_BLOB',
|
||||
seaBlob,
|
||||
seaPrepBlob,
|
||||
'--sentinel-fuse', 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2',
|
||||
...process.platform === 'darwin' ? [ '--macho-segment-name', 'NODE_SEA' ] : [],
|
||||
]);
|
||||
} catch (e) {
|
||||
const message = `Cannot inject ${seaBlob} into ${targetExecutable}: ${inspect(e)}`;
|
||||
const message = `Cannot inject ${seaPrepBlob} into ${outputFile}: ${inspect(e)}`;
|
||||
if (verifyWorkflow) {
|
||||
throw new Error(message);
|
||||
}
|
||||
common.skip(message);
|
||||
}
|
||||
console.log(`Injected ${seaBlob} into ${targetExecutable}`);
|
||||
console.log(`Injected ${seaPrepBlob} into ${outputFile}`);
|
||||
|
||||
signSEA(outputFile, verifyWorkflow);
|
||||
return outputFile;
|
||||
}
|
||||
|
||||
function signSEA(targetExecutable, verifyWorkflow = false) {
|
||||
if (process.platform === 'darwin') {
|
||||
try {
|
||||
spawnSyncAndExitWithoutError('codesign', [ '--sign', '-', targetExecutable ]);
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"assets": {
|
||||
"hello.node": "binding.node"
|
||||
}
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
const sea = require('node:sea');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const addonPath = path.join(process.cwd(), 'hello.node');
|
||||
fs.writeFileSync(addonPath, new Uint8Array(sea.getRawAsset('hello.node')));
|
||||
const mod = {exports: {}};
|
||||
process.dlopen(mod, addonPath);
|
||||
console.log('hello,', mod.exports.hello());
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob"
|
||||
}
|
||||
File renamed without changes.
+1
@@ -0,0 +1 @@
|
||||
This is asset 1
|
||||
+1
@@ -0,0 +1 @@
|
||||
This is asset 2
|
||||
+1
@@ -0,0 +1 @@
|
||||
This is asset 3
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { isSea, getAssetKeys } = require('node:sea');
|
||||
const assert = require('node:assert');
|
||||
|
||||
assert(isSea());
|
||||
|
||||
const keys = getAssetKeys();
|
||||
console.log('Asset keys:', JSON.stringify(keys.sort()));
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"assets": "invalid"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
// This file is used for testing invalid "assets" configuration.
|
||||
// It should not be executed because the configuration should fail.
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"assets": {
|
||||
"nonexistent": "nonexistent.txt"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
// This file is used for testing nonexistent asset file.
|
||||
// It should not be executed because the configuration should fail.
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"assets": {
|
||||
"person.jpg": "person.jpg"
|
||||
}
|
||||
}
|
||||
File renamed without changes.
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"assets": {
|
||||
"utf8_test_text.txt": "utf8_test_text.txt",
|
||||
"person.jpg": "person.jpg"
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+1
@@ -0,0 +1 @@
|
||||
永和九年,嵗在癸丑,暮春之初,會於會稽山隂之蘭亭,脩稧事也。羣賢畢至,少長咸集。此地有崇山峻領,茂林脩竹;又有清流激湍,暎帶左右。引以為流觴曲水,列坐其次。雖無絲竹管弦之盛,一觴一詠,亦足以暢敘幽情。是日也,天朗氣清,恵風和暢;仰觀宇宙之大,俯察品類之盛;所以遊目騁懐,足以極視聽之娛,信可樂也。夫人之相與,俯仰一世,或取諸懐抱,悟言一室之內,或因寄所託,放浪形骸之外。雖趣舎萬殊,靜躁不同,當其欣扵所遇,暫得扵己,怏然自足,不知老之將至。及其所之既惓,情隨事遷,感慨係之矣。向之所欣,俛仰之閒以為陳跡,猶不能不以之興懐;況脩短隨化,終期扵盡。古人云:「死生亦大矣。」豈不痛哉!每攬昔人興感之由,若合一契,未嘗不臨文嗟悼,不能喻之扵懐。固知一死生為虛誕,齊彭殤為妄作。後之視今,亦由今之視昔,悲夫!故列敘時人,錄其所述,雖世殊事異,所以興懐,其致一也。後之攬者,亦將有感扵斯文。
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
hello: 'world',
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
const { Module: { createRequire } } = require('module');
|
||||
const createdRequire = createRequire(__filename);
|
||||
|
||||
// Although, require('../common') works locally, that couldn't be used here
|
||||
// because we set NODE_TEST_DIR=/Users/iojs/node-tmp on Jenkins CI.
|
||||
const { expectWarning, mustNotCall } = createdRequire(process.env.COMMON_DIRECTORY);
|
||||
|
||||
const builtinWarning =
|
||||
`Currently the require() provided to the main script embedded into single-executable applications only supports loading built-in modules.
|
||||
To load a module from disk after the single executable application is launched, use require("module").createRequire().
|
||||
Support for bundled module loading or virtual file systems are under discussions in https://github.com/nodejs/single-executable`;
|
||||
|
||||
// This additionally makes sure that no unexpected warnings are emitted.
|
||||
if (!createdRequire('./sea-config.json').disableExperimentalSEAWarning) {
|
||||
expectWarning('Warning', builtinWarning); // Triggered by require() calls below.
|
||||
expectWarning('ExperimentalWarning',
|
||||
'Single executable application is an experimental feature and ' +
|
||||
'might change at any time');
|
||||
// Any unexpected warning would throw this error:
|
||||
// https://github.com/nodejs/node/blob/c301404105a7256b79a0b8c4522ce47af96dfa17/test/common/index.js#L697-L700.
|
||||
}
|
||||
|
||||
// Should be possible to require core modules that optionally require the
|
||||
// "node:" scheme.
|
||||
const { deepStrictEqual, strictEqual, throws } = require('assert');
|
||||
const { dirname } = require('node:path');
|
||||
|
||||
// Checks that the source filename is used in the error stack trace.
|
||||
strictEqual(new Error('lol').stack.split('\n')[1], ' at sea.js:29:13');
|
||||
|
||||
// Should be possible to require a core module that requires using the "node:"
|
||||
// scheme.
|
||||
{
|
||||
const { test } = require('node:test');
|
||||
strictEqual(typeof test, 'function');
|
||||
}
|
||||
|
||||
// Should not be possible to require a core module without the "node:" scheme if
|
||||
// it requires using the "node:" scheme.
|
||||
throws(() => require('test'), {
|
||||
code: 'ERR_UNKNOWN_BUILTIN_MODULE',
|
||||
});
|
||||
|
||||
deepStrictEqual(process.argv, [process.execPath, process.execPath, '-a', '--b=c', 'd']);
|
||||
|
||||
strictEqual(require.cache, undefined);
|
||||
strictEqual(require.extensions, undefined);
|
||||
strictEqual(require.main, module);
|
||||
strictEqual(require.resolve, undefined);
|
||||
|
||||
strictEqual(__filename, process.execPath);
|
||||
strictEqual(__dirname, dirname(process.execPath));
|
||||
strictEqual(module.exports, exports);
|
||||
|
||||
throws(() => require('./requirable.js'), {
|
||||
code: 'ERR_UNKNOWN_BUILTIN_MODULE',
|
||||
});
|
||||
|
||||
const requirable = createdRequire('./requirable.js');
|
||||
deepStrictEqual(requirable, {
|
||||
hello: 'world',
|
||||
});
|
||||
|
||||
console.log('Hello, world! 😊');
|
||||
Whitespace-only changes.
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "empty.js",
|
||||
"output": "sea-prep.blob"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": []
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
const assert = require('assert');
|
||||
|
||||
console.log('process.argv:', JSON.stringify(process.argv));
|
||||
assert.strictEqual(process.argv[2], 'user-arg');
|
||||
assert.deepStrictEqual(process.execArgv, []);
|
||||
console.log('empty execArgv test passed');
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": ["--no-warnings"],
|
||||
"execArgvExtension": "cli"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
const assert = require('assert');
|
||||
|
||||
console.log('process.argv:', JSON.stringify(process.argv));
|
||||
console.log('process.execArgv:', JSON.stringify(process.execArgv));
|
||||
|
||||
// Should have execArgv from SEA config + CLI --node-options
|
||||
assert.deepStrictEqual(process.execArgv, ['--no-warnings', '--max-old-space-size=1024']);
|
||||
|
||||
assert.deepStrictEqual(process.argv.slice(2), [
|
||||
'user-arg1',
|
||||
'user-arg2'
|
||||
]);
|
||||
|
||||
console.log('execArgvExtension cli test passed');
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": ["--no-warnings"],
|
||||
"execArgvExtension": "env"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
const assert = require('assert');
|
||||
|
||||
process.emitWarning('This warning should not be shown in the output', 'TestWarning');
|
||||
|
||||
console.log('process.argv:', JSON.stringify(process.argv));
|
||||
console.log('process.execArgv:', JSON.stringify(process.execArgv));
|
||||
|
||||
// Should have execArgv from SEA config.
|
||||
// Note that flags from NODE_OPTIONS are not included in process.execArgv no matter it's
|
||||
// an SEA or not, but we can test whether it works by checking that the warning emitted
|
||||
// above was silenced.
|
||||
assert.deepStrictEqual(process.execArgv, ['--no-warnings']);
|
||||
|
||||
assert.deepStrictEqual(process.argv.slice(2), [
|
||||
'user-arg1',
|
||||
'user-arg2'
|
||||
]);
|
||||
|
||||
console.log('execArgvExtension env test passed');
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": ["--no-warnings"],
|
||||
"execArgvExtension": "none"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
const assert = require('assert');
|
||||
|
||||
console.log('process.argv:', JSON.stringify(process.argv));
|
||||
console.log('process.execArgv:', JSON.stringify(process.execArgv));
|
||||
|
||||
// Should only have execArgv from SEA config, no NODE_OPTIONS
|
||||
assert.deepStrictEqual(process.execArgv, ['--no-warnings']);
|
||||
|
||||
assert.deepStrictEqual(process.argv.slice(2), [
|
||||
'user-arg1',
|
||||
'user-arg2'
|
||||
]);
|
||||
|
||||
console.log('execArgvExtension none test passed');
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": ["--no-warnings", "--max-old-space-size=2048"]
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
const assert = require('assert');
|
||||
|
||||
process.emitWarning('This warning should not be shown in the output', 'TestWarning');
|
||||
|
||||
console.log('process.argv:', JSON.stringify(process.argv));
|
||||
console.log('process.execArgv:', JSON.stringify(process.execArgv));
|
||||
|
||||
assert.deepStrictEqual(process.execArgv, [ '--no-warnings', '--max-old-space-size=2048' ]);
|
||||
|
||||
// We start from 2, because in SEA, the index 1 would be the same as the execPath
|
||||
// to accommodate the general expectation that index 1 is the path to script for
|
||||
// applications.
|
||||
assert.deepStrictEqual(process.argv.slice(2), [
|
||||
'user-arg1',
|
||||
'user-arg2'
|
||||
]);
|
||||
|
||||
console.log('multiple execArgv test passed');
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
console.log(process.argv);
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
console.log('Hello, world!');
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "hello.js",
|
||||
"output": "sea-prep.blob"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
hello: 'world',
|
||||
};
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "snapshot.blob",
|
||||
"disableExperimentalSEAWarning": true
|
||||
}
|
||||
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
const { Module: { createRequire } } = require('module');
|
||||
const createdRequire = createRequire(__filename);
|
||||
|
||||
// Although, require('../common') works locally, that couldn't be used here
|
||||
// because we set NODE_TEST_DIR=/Users/iojs/node-tmp on Jenkins CI.
|
||||
const { expectWarning, mustNotCall } = createdRequire(process.env.COMMON_DIRECTORY);
|
||||
|
||||
const builtinWarning =
|
||||
`Currently the require() provided to the main script embedded into single-executable applications only supports loading built-in modules.
|
||||
To load a module from disk after the single executable application is launched, use require("module").createRequire().
|
||||
Support for bundled module loading or virtual file systems are under discussions in https://github.com/nodejs/single-executable`;
|
||||
|
||||
// This additionally makes sure that no unexpected warnings are emitted.
|
||||
if (!createdRequire('./sea-config.json').disableExperimentalSEAWarning) {
|
||||
expectWarning('Warning', builtinWarning); // Triggered by require() calls below.
|
||||
expectWarning('ExperimentalWarning',
|
||||
'Single executable application is an experimental feature and ' +
|
||||
'might change at any time');
|
||||
// Any unexpected warning would throw this error:
|
||||
// https://github.com/nodejs/node/blob/c301404105a7256b79a0b8c4522ce47af96dfa17/test/common/index.js#L697-L700.
|
||||
}
|
||||
|
||||
// Should be possible to require core modules that optionally require the
|
||||
// "node:" scheme.
|
||||
const { deepStrictEqual, strictEqual, throws } = require('assert');
|
||||
const { dirname } = require('node:path');
|
||||
|
||||
// Checks that the source filename is used in the error stack trace.
|
||||
strictEqual(new Error('lol').stack.split('\n')[1], ' at sea.js:29:13');
|
||||
|
||||
// Should be possible to require a core module that requires using the "node:"
|
||||
// scheme.
|
||||
{
|
||||
const { test } = require('node:test');
|
||||
strictEqual(typeof test, 'function');
|
||||
}
|
||||
|
||||
// Should not be possible to require a core module without the "node:" scheme if
|
||||
// it requires using the "node:" scheme.
|
||||
throws(() => require('test'), {
|
||||
code: 'ERR_UNKNOWN_BUILTIN_MODULE',
|
||||
});
|
||||
|
||||
deepStrictEqual(process.argv, [process.execPath, process.execPath, '-a', '--b=c', 'd']);
|
||||
|
||||
strictEqual(require.cache, undefined);
|
||||
strictEqual(require.extensions, undefined);
|
||||
strictEqual(require.main, module);
|
||||
strictEqual(require.resolve, undefined);
|
||||
|
||||
strictEqual(__filename, process.execPath);
|
||||
strictEqual(__dirname, dirname(process.execPath));
|
||||
strictEqual(module.exports, exports);
|
||||
|
||||
throws(() => require('./requirable.js'), {
|
||||
code: 'ERR_UNKNOWN_BUILTIN_MODULE',
|
||||
});
|
||||
|
||||
const requirable = createdRequire('./requirable.js');
|
||||
deepStrictEqual(requirable, {
|
||||
hello: 'world',
|
||||
});
|
||||
|
||||
console.log('Hello, world! 😊');
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
"output": "sea-prep.blob",
|
||||
"useSnapshot": true,
|
||||
"useCodeCache": true
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
const {
|
||||
setDeserializeMainFunction,
|
||||
} = require('v8').startupSnapshot;
|
||||
|
||||
setDeserializeMainFunction(() => {
|
||||
console.log('Hello from snapshot');
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
"output": "sea-prep.blob",
|
||||
"useSnapshot": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
const {
|
||||
setDeserializeMainFunction,
|
||||
} = require('v8').startupSnapshot;
|
||||
|
||||
setDeserializeMainFunction(() => {
|
||||
const { Worker } = require('worker_threads');
|
||||
new Worker("console.log('Hello from Worker')", { eval: true });
|
||||
});
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
"output": "sea-prep.blob",
|
||||
"useSnapshot": true
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
const {
|
||||
setDeserializeMainFunction,
|
||||
} = require('v8').startupSnapshot;
|
||||
|
||||
setDeserializeMainFunction(() => {
|
||||
console.log('Hello from snapshot');
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
hello: 'world',
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"useCodeCache": true
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
const { Module: { createRequire } } = require('module');
|
||||
const createdRequire = createRequire(__filename);
|
||||
|
||||
// Although, require('../common') works locally, that couldn't be used here
|
||||
// because we set NODE_TEST_DIR=/Users/iojs/node-tmp on Jenkins CI.
|
||||
const { expectWarning, mustNotCall } = createdRequire(process.env.COMMON_DIRECTORY);
|
||||
|
||||
const builtinWarning =
|
||||
`Currently the require() provided to the main script embedded into single-executable applications only supports loading built-in modules.
|
||||
To load a module from disk after the single executable application is launched, use require("module").createRequire().
|
||||
Support for bundled module loading or virtual file systems are under discussions in https://github.com/nodejs/single-executable`;
|
||||
|
||||
// This additionally makes sure that no unexpected warnings are emitted.
|
||||
if (!createdRequire('./sea-config.json').disableExperimentalSEAWarning) {
|
||||
expectWarning('Warning', builtinWarning); // Triggered by require() calls below.
|
||||
expectWarning('ExperimentalWarning',
|
||||
'Single executable application is an experimental feature and ' +
|
||||
'might change at any time');
|
||||
// Any unexpected warning would throw this error:
|
||||
// https://github.com/nodejs/node/blob/c301404105a7256b79a0b8c4522ce47af96dfa17/test/common/index.js#L697-L700.
|
||||
}
|
||||
|
||||
// Should be possible to require core modules that optionally require the
|
||||
// "node:" scheme.
|
||||
const { deepStrictEqual, strictEqual, throws } = require('assert');
|
||||
const { dirname } = require('node:path');
|
||||
|
||||
// Checks that the source filename is used in the error stack trace.
|
||||
strictEqual(new Error('lol').stack.split('\n')[1], ' at sea.js:29:13');
|
||||
|
||||
// Should be possible to require a core module that requires using the "node:"
|
||||
// scheme.
|
||||
{
|
||||
const { test } = require('node:test');
|
||||
strictEqual(typeof test, 'function');
|
||||
}
|
||||
|
||||
// Should not be possible to require a core module without the "node:" scheme if
|
||||
// it requires using the "node:" scheme.
|
||||
throws(() => require('test'), {
|
||||
code: 'ERR_UNKNOWN_BUILTIN_MODULE',
|
||||
});
|
||||
|
||||
deepStrictEqual(process.argv, [process.execPath, process.execPath, '-a', '--b=c', 'd']);
|
||||
|
||||
strictEqual(require.cache, undefined);
|
||||
strictEqual(require.extensions, undefined);
|
||||
strictEqual(require.main, module);
|
||||
strictEqual(require.resolve, undefined);
|
||||
|
||||
strictEqual(__filename, process.execPath);
|
||||
strictEqual(__dirname, dirname(process.execPath));
|
||||
strictEqual(module.exports, exports);
|
||||
|
||||
throws(() => require('./requirable.js'), {
|
||||
code: 'ERR_UNKNOWN_BUILTIN_MODULE',
|
||||
});
|
||||
|
||||
const requirable = createdRequire('./requirable.js');
|
||||
deepStrictEqual(requirable, {
|
||||
hello: 'world',
|
||||
});
|
||||
|
||||
console.log('Hello, world! 😊');
|
||||
@@ -6,57 +6,30 @@ const { generateSEA, skipIfSingleExecutableIsNotSupported } = require('../../com
|
||||
|
||||
skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
const tmpdir = require('../../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync, rmSync } = require('fs');
|
||||
const { copyFileSync, rmSync, cpSync } = require('fs');
|
||||
const {
|
||||
spawnSyncAndExitWithoutError,
|
||||
spawnSyncAndAssert,
|
||||
} = require('../../common/child_process');
|
||||
const { join } = require('path');
|
||||
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();
|
||||
const fixtures = require('../../common/fixtures');
|
||||
|
||||
// Copy test fixture to working directory
|
||||
const addonPath = join(__dirname, 'build', common.buildType, 'binding.node');
|
||||
const copiedAddonPath = tmpdir.resolve('binding.node');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
// Copy fixture files to working directory.
|
||||
const fixtureDir = fixtures.path('sea', 'addon');
|
||||
cpSync(fixtureDir, tmpdir.path, { recursive: true });
|
||||
|
||||
// Copy the built addon to working directory.
|
||||
copyFileSync(addonPath, copiedAddonPath);
|
||||
writeFileSync(tmpdir.resolve('sea.js'), `
|
||||
const sea = require('node:sea');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const addonPath = path.join(${JSON.stringify(tmpdir.path)}, 'hello.node');
|
||||
fs.writeFileSync(addonPath, new Uint8Array(sea.getRawAsset('hello.node')));
|
||||
const mod = {exports: {}}
|
||||
process.dlopen(mod, addonPath);
|
||||
console.log('hello,', mod.exports.hello());
|
||||
`, 'utf-8');
|
||||
// Generate the SEA using the working directory directly (skip copy).
|
||||
const outputFile = generateSEA(tmpdir.path, tmpdir.path);
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"assets": {
|
||||
"hello.node": "binding.node"
|
||||
}
|
||||
}
|
||||
`, 'utf8');
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path },
|
||||
);
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
|
||||
// Remove the copied addon after it's been packaged into the SEA blob
|
||||
// Remove the copied addon after it's been packaged into the SEA blob.
|
||||
rmSync(copiedAddonPath, { force: true });
|
||||
|
||||
spawnSyncAndAssert(
|
||||
|
||||
@@ -14,42 +14,14 @@ 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);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'asset-keys-empty'));
|
||||
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
|
||||
@@ -14,51 +14,14 @@ 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);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'asset-keys'));
|
||||
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
// Test that invalid "assets" field (not a map) is rejected.
|
||||
|
||||
require('../common');
|
||||
const {
|
||||
spawnSyncAndExit,
|
||||
} = require('../common/child_process');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync } = require('fs');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
// Copy the fixture files to tmpdir
|
||||
copyFileSync(
|
||||
fixtures.path('sea', 'assets-invalid-type', 'sea-config.json'),
|
||||
tmpdir.resolve('sea-config.json'),
|
||||
);
|
||||
copyFileSync(
|
||||
fixtures.path('sea', 'assets-invalid-type', 'sea.js'),
|
||||
tmpdir.resolve('sea.js'),
|
||||
);
|
||||
|
||||
spawnSyncAndExit(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path,
|
||||
},
|
||||
{
|
||||
status: 1,
|
||||
signal: null,
|
||||
stderr: /"assets" field of .*sea-config\.json is not a map of strings/,
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
// Test that nonexistent asset file is rejected.
|
||||
|
||||
const common = require('../common'); // eslint-disable-line no-unused-vars
|
||||
const {
|
||||
spawnSyncAndExit,
|
||||
} = require('../common/child_process');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync } = require('fs');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
// Copy the fixture files to tmpdir
|
||||
copyFileSync(
|
||||
fixtures.path('sea', 'assets-nonexistent-file', 'sea-config.json'),
|
||||
tmpdir.resolve('sea-config.json'),
|
||||
);
|
||||
copyFileSync(
|
||||
fixtures.path('sea', 'assets-nonexistent-file', 'sea.js'),
|
||||
tmpdir.resolve('sea.js'),
|
||||
);
|
||||
|
||||
spawnSyncAndExit(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path,
|
||||
},
|
||||
{
|
||||
status: 1,
|
||||
signal: null,
|
||||
stderr: /Cannot read asset nonexistent\.txt: no such file or directory/,
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
require('../common');
|
||||
const {
|
||||
generateSEA,
|
||||
skipIfSingleExecutableIsNotSupported,
|
||||
@@ -12,59 +11,21 @@ skipIfSingleExecutableIsNotSupported();
|
||||
// This tests the snapshot support in single executable applications.
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const {
|
||||
spawnSyncAndExitWithoutError,
|
||||
} = require('../common/child_process');
|
||||
const assert = require('assert');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
if (!tmpdir.hasEnoughSpace(120 * 1024 * 1024)) {
|
||||
common.skip('Not enough disk space');
|
||||
}
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'assets-raw'));
|
||||
|
||||
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-raw.js'), tmpdir.resolve('sea.js'));
|
||||
copyFileSync(fixtures.path('person.jpg'), tmpdir.resolve('person.jpg'));
|
||||
writeFileSync(configFile, `
|
||||
spawnSyncAndExitWithoutError(
|
||||
outputFile,
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"assets": {
|
||||
"person.jpg": "person.jpg"
|
||||
}
|
||||
}
|
||||
`, '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);
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
outputFile,
|
||||
{
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_DEBUG_NATIVE: 'SEA',
|
||||
__TEST_PERSON_JPG: fixtures.path('person.jpg'),
|
||||
},
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_DEBUG_NATIVE: 'SEA',
|
||||
__TEST_PERSON_JPG: fixtures.path('person.jpg'),
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
// This tests the assets support in single executable applications.
|
||||
|
||||
require('../common');
|
||||
const {
|
||||
generateSEA,
|
||||
skipIfSingleExecutableIsNotSupported,
|
||||
@@ -9,121 +10,27 @@ const {
|
||||
|
||||
skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
// This tests the snapshot support in single executable applications.
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const {
|
||||
spawnSyncAndAssert,
|
||||
spawnSyncAndExit,
|
||||
spawnSyncAndExitWithoutError,
|
||||
} = require('../common/child_process');
|
||||
const assert = require('assert');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
if (!tmpdir.hasEnoughSpace(120 * 1024 * 1024)) {
|
||||
common.skip('Not enough disk space');
|
||||
}
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'assets'));
|
||||
|
||||
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.js'), tmpdir.resolve('sea.js'));
|
||||
writeFileSync(configFile, `
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"assets": "invalid"
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExit(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path,
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_DEBUG_NATIVE: 'SEA',
|
||||
__TEST_PERSON_JPG: fixtures.path('person.jpg'),
|
||||
__TEST_UTF8_TEXT_PATH: fixtures.path('utf8_test_text.txt'),
|
||||
},
|
||||
{
|
||||
status: 1,
|
||||
signal: null,
|
||||
stderr: /"assets" field of sea-config\.json is not a map of strings/,
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
copyFileSync(fixtures.path('sea', 'get-asset.js'), tmpdir.resolve('sea.js'));
|
||||
writeFileSync(configFile, `
|
||||
},
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"assets": {
|
||||
"nonexistent": "nonexistent.txt"
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExit(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path,
|
||||
},
|
||||
{
|
||||
status: 1,
|
||||
signal: null,
|
||||
stderr: /Cannot read asset nonexistent\.txt: no such file or directory/,
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
copyFileSync(fixtures.path('sea', 'get-asset.js'), tmpdir.resolve('sea.js'));
|
||||
copyFileSync(fixtures.utf8TestTextPath, tmpdir.resolve('utf8_test_text.txt'));
|
||||
copyFileSync(fixtures.path('person.jpg'), tmpdir.resolve('person.jpg'));
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"assets": {
|
||||
"utf8_test_text.txt": "utf8_test_text.txt",
|
||||
"person.jpg": "person.jpg"
|
||||
}
|
||||
}
|
||||
`, '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',
|
||||
__TEST_PERSON_JPG: fixtures.path('person.jpg'),
|
||||
__TEST_UTF8_TEXT_PATH: fixtures.path('utf8_test_text.txt'),
|
||||
},
|
||||
},
|
||||
{
|
||||
trim: true,
|
||||
stdout: fixtures.utf8TestText,
|
||||
},
|
||||
);
|
||||
}
|
||||
trim: true,
|
||||
stdout: fixtures.utf8TestText,
|
||||
},
|
||||
);
|
||||
@@ -12,45 +12,14 @@ skipIfSingleExecutableIsNotSupported();
|
||||
// This tests the creation of a single executable application which has the
|
||||
// experimental SEA warning disabled.
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const inputFile = fixtures.path('sea.js');
|
||||
const requirableFile = tmpdir.resolve('requirable.js');
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
writeFileSync(requirableFile, `
|
||||
module.exports = {
|
||||
hello: 'world',
|
||||
};
|
||||
`);
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true
|
||||
}
|
||||
`);
|
||||
|
||||
// Copy input to working directory
|
||||
copyFileSync(inputFile, tmpdir.resolve('sea.js'));
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path });
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'disable-experimental-warning'));
|
||||
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
|
||||
@@ -13,34 +13,16 @@ skipIfSingleExecutableIsNotSupported();
|
||||
// script.
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { writeFileSync, existsSync } = require('fs');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const assert = require('assert');
|
||||
|
||||
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();
|
||||
|
||||
writeFileSync(tmpdir.resolve('empty.js'), '', 'utf-8');
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "empty.js",
|
||||
"output": "sea-prep.blob"
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path });
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
// Verify the workflow.
|
||||
let outputFile;
|
||||
try {
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob, true);
|
||||
outputFile = generateSEA(fixtures.path('sea', 'empty'), {
|
||||
verifyWorkflow: true,
|
||||
});
|
||||
} catch (e) {
|
||||
if (/Cannot copy/.test(e.message)) {
|
||||
common.skip(e.message);
|
||||
|
||||
@@ -11,39 +11,14 @@ skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
// This tests the execArgv functionality with empty array in single executable applications.
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
// Copy test fixture to working directory
|
||||
copyFileSync(fixtures.path('sea-exec-argv-empty.js'), tmpdir.resolve('sea.js'));
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": []
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path });
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'exec-argv-empty'));
|
||||
|
||||
// Test that empty execArgv work correctly
|
||||
spawnSyncAndAssert(
|
||||
|
||||
@@ -11,40 +11,14 @@ skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
// This tests the execArgvExtension "cli" mode in single executable applications.
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
// Copy test fixture to working directory
|
||||
copyFileSync(fixtures.path('sea-exec-argv-extension-cli.js'), tmpdir.resolve('sea.js'));
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": ["--no-warnings"],
|
||||
"execArgvExtension": "cli"
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path });
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'exec-argv-extension-cli'));
|
||||
|
||||
// Test that --node-options works with execArgvExtension: "cli"
|
||||
spawnSyncAndAssert(
|
||||
|
||||
@@ -11,40 +11,15 @@ skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
// This tests the execArgvExtension "env" mode (default) in single executable applications.
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
// Copy test fixture to working directory
|
||||
copyFileSync(fixtures.path('sea-exec-argv-extension-env.js'), tmpdir.resolve('sea.js'));
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": ["--no-warnings"],
|
||||
"execArgvExtension": "env"
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path });
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'exec-argv-extension-env'));
|
||||
|
||||
// Test that NODE_OPTIONS works with execArgvExtension: "env" (default behavior)
|
||||
spawnSyncAndAssert(
|
||||
|
||||
@@ -11,40 +11,14 @@ skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
// This tests the execArgvExtension "none" mode in single executable applications.
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
// Copy test fixture to working directory
|
||||
copyFileSync(fixtures.path('sea-exec-argv-extension-none.js'), tmpdir.resolve('sea.js'));
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": ["--no-warnings"],
|
||||
"execArgvExtension": "none"
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path });
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'exec-argv-extension-none'));
|
||||
|
||||
// Test that NODE_OPTIONS is ignored with execArgvExtension: "none"
|
||||
spawnSyncAndAssert(
|
||||
|
||||
@@ -11,39 +11,15 @@ skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
// This tests the execArgv functionality with multiple arguments in single executable applications.
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
|
||||
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();
|
||||
|
||||
// Copy test fixture to working directory
|
||||
copyFileSync(fixtures.path('sea-exec-argv.js'), tmpdir.resolve('sea.js'));
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": true,
|
||||
"execArgv": ["--no-warnings", "--max-old-space-size=2048"]
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path });
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'exec-argv'));
|
||||
|
||||
// Test that multiple execArgv are properly applied
|
||||
spawnSyncAndAssert(
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const { writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const {
|
||||
generateSEA,
|
||||
@@ -18,33 +17,9 @@ const {
|
||||
|
||||
skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
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();
|
||||
|
||||
writeFileSync(tmpdir.resolve('sea.js'), `console.log(process.argv);`, 'utf-8');
|
||||
|
||||
// Create SEA configuration
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob"
|
||||
}
|
||||
`);
|
||||
|
||||
// Generate the SEA prep blob
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path },
|
||||
);
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
// Generate the SEA executable
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'inspect-in-sea-flags'));
|
||||
|
||||
// Spawn the SEA with inspect option
|
||||
spawnSyncAndAssert(
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { writeFileSync, existsSync } = require('fs');
|
||||
const { spawn } = require('child_process');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const {
|
||||
generateSEA,
|
||||
@@ -18,34 +17,9 @@ const {
|
||||
skipIfSingleExecutableIsNotSupported();
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
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();
|
||||
|
||||
// Create a simple hello world script
|
||||
writeFileSync(tmpdir.resolve('hello.js'), `console.log('Hello, world!');`, 'utf-8');
|
||||
|
||||
// Create SEA configuration
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "hello.js",
|
||||
"output": "sea-prep.blob"
|
||||
}
|
||||
`);
|
||||
|
||||
// Generate the SEA prep blob
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path },
|
||||
);
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
// Generate the SEA executable
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'inspect'));
|
||||
|
||||
// Spawn the SEA with inspect option
|
||||
const seaProcess = spawn(outputFile, [], {
|
||||
|
||||
@@ -12,57 +12,15 @@ skipIfSingleExecutableIsNotSupported();
|
||||
// This tests "useCodeCache" is ignored when "useSnapshot" is true.
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { writeFileSync, existsSync } = require('fs');
|
||||
const {
|
||||
spawnSyncAndAssert,
|
||||
} = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = join(tmpdir.path, 'sea-config.json');
|
||||
const seaPrepBlob = join(tmpdir.path, 'sea-prep.blob');
|
||||
const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const code = `
|
||||
const {
|
||||
setDeserializeMainFunction,
|
||||
} = require('v8').startupSnapshot;
|
||||
|
||||
setDeserializeMainFunction(() => {
|
||||
console.log('Hello from snapshot');
|
||||
});
|
||||
`;
|
||||
|
||||
writeFileSync(join(tmpdir.path, 'snapshot.js'), code, 'utf-8');
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
"output": "sea-prep.blob",
|
||||
"useSnapshot": true,
|
||||
"useCodeCache": true
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndAssert(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path,
|
||||
env: {
|
||||
NODE_DEBUG_NATIVE: 'SEA',
|
||||
...process.env,
|
||||
},
|
||||
},
|
||||
{
|
||||
stderr: /"useCodeCache" is redundant when "useSnapshot" is true/,
|
||||
},
|
||||
);
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'snapshot-and-code-cache'));
|
||||
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
|
||||
@@ -12,57 +12,15 @@ skipIfSingleExecutableIsNotSupported();
|
||||
// This tests the snapshot support in single executable applications.
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { writeFileSync, existsSync } = require('fs');
|
||||
const {
|
||||
spawnSyncAndAssert, spawnSyncAndExitWithoutError,
|
||||
spawnSyncAndAssert,
|
||||
} = require('../common/child_process');
|
||||
const assert = require('assert');
|
||||
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
|
||||
// FIXME(joyeecheung): currently `worker_threads` cannot be loaded during the
|
||||
// snapshot building process because internal/worker.js is accessing isMainThread at
|
||||
// the top level (and there are maybe more code that access these at the top-level),
|
||||
// and have to be loaded in the deserialized snapshot main function.
|
||||
// Change these states to be accessed on-demand.
|
||||
const code = `
|
||||
const {
|
||||
setDeserializeMainFunction,
|
||||
} = require('v8').startupSnapshot;
|
||||
setDeserializeMainFunction(() => {
|
||||
const { Worker } = require('worker_threads');
|
||||
new Worker("console.log('Hello from Worker')", { eval: true });
|
||||
});
|
||||
`;
|
||||
|
||||
writeFileSync(tmpdir.resolve('snapshot.js'), code, 'utf-8');
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
"output": "sea-prep.blob",
|
||||
"useSnapshot": true
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path,
|
||||
env: {
|
||||
NODE_DEBUG_NATIVE: 'SEA',
|
||||
...process.env,
|
||||
},
|
||||
});
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'snapshot-worker'));
|
||||
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
|
||||
@@ -12,22 +12,19 @@ skipIfSingleExecutableIsNotSupported();
|
||||
// This tests the snapshot support in single executable applications.
|
||||
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { writeFileSync, existsSync } = require('fs');
|
||||
const { writeFileSync } = require('fs');
|
||||
const {
|
||||
spawnSyncAndAssert,
|
||||
spawnSyncAndExit,
|
||||
} = require('../common/child_process');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
|
||||
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();
|
||||
|
||||
writeFileSync(tmpdir.resolve('snapshot.js'), '', 'utf-8');
|
||||
writeFileSync(configFile, `
|
||||
writeFileSync(tmpdir.resolve('sea-config.json'), `
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
"output": "sea-prep.blob",
|
||||
@@ -50,42 +47,8 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const code = `
|
||||
const {
|
||||
setDeserializeMainFunction,
|
||||
} = require('v8').startupSnapshot;
|
||||
|
||||
setDeserializeMainFunction(() => {
|
||||
console.log('Hello from snapshot');
|
||||
});
|
||||
`;
|
||||
|
||||
writeFileSync(tmpdir.resolve('snapshot.js'), code, 'utf-8');
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "snapshot.js",
|
||||
"output": "sea-prep.blob",
|
||||
"useSnapshot": true
|
||||
}
|
||||
`);
|
||||
|
||||
spawnSyncAndAssert(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path,
|
||||
env: {
|
||||
NODE_DEBUG_NATIVE: 'SEA',
|
||||
...process.env,
|
||||
},
|
||||
},
|
||||
{
|
||||
stderr: /Single executable application is an experimental feature/,
|
||||
});
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'snapshot'));
|
||||
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
|
||||
@@ -12,51 +12,14 @@ skipIfSingleExecutableIsNotSupported();
|
||||
// This tests the creation of a single executable application which uses the
|
||||
// V8 code cache.
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const inputFile = fixtures.path('sea.js');
|
||||
const requirableFile = tmpdir.resolve('requirable.js');
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
writeFileSync(requirableFile, `
|
||||
module.exports = {
|
||||
hello: 'world',
|
||||
};
|
||||
`);
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"useCodeCache": true
|
||||
}
|
||||
`);
|
||||
|
||||
// Copy input to working directory
|
||||
copyFileSync(inputFile, tmpdir.resolve('sea.js'));
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{
|
||||
cwd: tmpdir.path,
|
||||
env: {
|
||||
NODE_DEBUG_NATIVE: 'SEA',
|
||||
...process.env,
|
||||
},
|
||||
});
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'use-code-cache'));
|
||||
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
|
||||
@@ -11,45 +11,14 @@ skipIfSingleExecutableIsNotSupported();
|
||||
|
||||
// This tests the creation of a single executable application.
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const { copyFileSync, writeFileSync, existsSync } = require('fs');
|
||||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const { join } = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
const inputFile = fixtures.path('sea.js');
|
||||
const requirableFile = tmpdir.resolve('requirable.js');
|
||||
const configFile = tmpdir.resolve('sea-config.json');
|
||||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob');
|
||||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
tmpdir.refresh();
|
||||
|
||||
writeFileSync(requirableFile, `
|
||||
module.exports = {
|
||||
hello: 'world',
|
||||
};
|
||||
`);
|
||||
|
||||
writeFileSync(configFile, `
|
||||
{
|
||||
"main": "sea.js",
|
||||
"output": "sea-prep.blob",
|
||||
"disableExperimentalSEAWarning": false
|
||||
}
|
||||
`);
|
||||
|
||||
// Copy input to working directory
|
||||
copyFileSync(inputFile, tmpdir.resolve('sea.js'));
|
||||
spawnSyncAndExitWithoutError(
|
||||
process.execPath,
|
||||
['--experimental-sea-config', 'sea-config.json'],
|
||||
{ cwd: tmpdir.path });
|
||||
|
||||
assert(existsSync(seaPrepBlob));
|
||||
|
||||
generateSEA(outputFile, process.execPath, seaPrepBlob);
|
||||
const outputFile = generateSEA(fixtures.path('sea', 'simple'));
|
||||
|
||||
spawnSyncAndAssert(
|
||||
outputFile,
|
||||
|
||||
Reference in new issue
Block a user