-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sea: add option to disable the experimental SEA warning
Refs: nodejs/single-executable#60 Signed-off-by: Darshan Sen <raisinten@gmail.com>
- Loading branch information
Showing
10 changed files
with
311 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
test/parallel/test-single-executable-application-disable-experimental-sea-warning.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This tests the creation of a single executable application. | ||
|
||
const fixtures = require('../common/fixtures'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const { copyFileSync, readFileSync, writeFileSync, existsSync } = require('fs'); | ||
const { execFileSync } = require('child_process'); | ||
const { join } = require('path'); | ||
const { strictEqual } = require('assert'); | ||
const assert = require('assert'); | ||
|
||
if (!process.config.variables.single_executable_application) | ||
common.skip('Single Executable Application support has been disabled.'); | ||
|
||
if (!['darwin', 'win32', 'linux'].includes(process.platform)) | ||
common.skip(`Unsupported platform ${process.platform}.`); | ||
|
||
if (process.platform === 'linux' && process.config.variables.is_debug === 1) | ||
common.skip('Running the resultant binary fails with `Couldn\'t read target executable"`.'); | ||
|
||
if (process.config.variables.node_shared) | ||
common.skip('Running the resultant binary fails with ' + | ||
'`/home/iojs/node-tmp/.tmp.2366/sea: error while loading shared libraries: ' + | ||
'libnode.so.112: cannot open shared object file: No such file or directory`.'); | ||
|
||
if (process.config.variables.icu_gyp_path === 'tools/icu/icu-system.gyp') | ||
common.skip('Running the resultant binary fails with ' + | ||
'`/home/iojs/node-tmp/.tmp.2379/sea: error while loading shared libraries: ' + | ||
'libicui18n.so.71: cannot open shared object file: No such file or directory`.'); | ||
|
||
if (!process.config.variables.node_use_openssl || process.config.variables.node_shared_openssl) | ||
common.skip('Running the resultant binary fails with `Node.js is not compiled with OpenSSL crypto support`.'); | ||
|
||
if (process.config.variables.want_separate_host_toolset !== 0) | ||
common.skip('Running the resultant binary fails with `Segmentation fault (core dumped)`.'); | ||
|
||
if (process.platform === 'linux') { | ||
const osReleaseText = readFileSync('/etc/os-release', { encoding: 'utf-8' }); | ||
const isAlpine = /^NAME="Alpine Linux"/m.test(osReleaseText); | ||
if (isAlpine) common.skip('Alpine Linux is not supported.'); | ||
|
||
if (process.arch === 's390x') { | ||
common.skip('On s390x, postject fails with `memory access out of bounds`.'); | ||
} | ||
|
||
if (process.arch === 'ppc64') { | ||
common.skip('On ppc64, this test times out.'); | ||
} | ||
} | ||
|
||
const inputFile = fixtures.path('sea.js'); | ||
const requirableFile = join(tmpdir.path, 'requirable.js'); | ||
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'); | ||
|
||
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, join(tmpdir.path, 'sea.js')); | ||
execFileSync(process.execPath, ['--experimental-sea-config', 'sea-config.json'], { | ||
cwd: tmpdir.path | ||
}); | ||
|
||
assert(existsSync(seaPrepBlob)); | ||
|
||
copyFileSync(process.execPath, outputFile); | ||
const postjectFile = fixtures.path('postject-copy', 'node_modules', 'postject', 'dist', 'cli.js'); | ||
execFileSync(process.execPath, [ | ||
postjectFile, | ||
outputFile, | ||
'NODE_SEA_BLOB', | ||
seaPrepBlob, | ||
'--sentinel-fuse', 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2', | ||
...process.platform === 'darwin' ? [ '--macho-segment-name', 'NODE_SEA' ] : [], | ||
]); | ||
|
||
if (process.platform === 'darwin') { | ||
execFileSync('codesign', [ '--sign', '-', outputFile ]); | ||
execFileSync('codesign', [ '--verify', outputFile ]); | ||
} else if (process.platform === 'win32') { | ||
let signtoolFound = false; | ||
try { | ||
execFileSync('where', [ 'signtool' ]); | ||
signtoolFound = true; | ||
} catch (err) { | ||
console.log(err.message); | ||
} | ||
if (signtoolFound) { | ||
let certificatesFound = false; | ||
try { | ||
execFileSync('signtool', [ 'sign', '/fd', 'SHA256', outputFile ]); | ||
certificatesFound = true; | ||
} catch (err) { | ||
if (!/SignTool Error: No certificates were found that met all the given criteria/.test(err)) { | ||
throw err; | ||
} | ||
} | ||
if (certificatesFound) { | ||
execFileSync('signtool', 'verify', '/pa', 'SHA256', outputFile); | ||
} | ||
} | ||
} | ||
|
||
const singleExecutableApplicationOutput = execFileSync( | ||
outputFile, | ||
[ '-a', '--b=c', 'd' ], | ||
{ env: { COMMON_DIRECTORY: join(__dirname, '..', 'common') } }); | ||
strictEqual(singleExecutableApplicationOutput.toString(), 'Hello, world! 😊\n'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.