Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fcc6d54
lib: return directly if udp socket close before lookup
theanarkh Mar 1, 2024
5034363
src: fix --disable-single-executable-application
joyeecheung Feb 19, 2024
e992af8
test: skip SEA tests when SEA generation fails
joyeecheung Feb 26, 2024
5908c12
doc: clarify Corepack threat model
aduh95 Mar 1, 2024
9d2c039
test: remove flaky designation
lpinca Mar 2, 2024
20e0ba3
doc,module: clarify hook chain execution sequence
JakobJingleheimer Mar 2, 2024
87d2acc
doc: fix actual result of example is different in events
deokjinkim Mar 2, 2024
fcf235d
doc: add policy for distribution
GeoffreyBooth Mar 3, 2024
9617adc
Revert "build: fix warning in cares under GN build"
lpinca Mar 3, 2024
4d99797
lib: make sure close net server
theanarkh Mar 3, 2024
67e8001
meta: bump actions/setup-node from 4.0.1 to 4.0.2
dependabot[bot] Mar 3, 2024
e476cb4
meta: bump actions/download-artifact from 4.1.1 to 4.1.3
dependabot[bot] Mar 3, 2024
015a157
meta: bump actions/cache from 4.0.0 to 4.0.1
dependabot[bot] Mar 3, 2024
42ca545
meta: bump codecov/codecov-action from 4.0.1 to 4.1.0
dependabot[bot] Mar 3, 2024
78f38a0
meta: bump actions/upload-artifact from 4.3.0 to 4.3.1
dependabot[bot] Mar 3, 2024
10aaabd
meta: bump github/codeql-action from 3.23.2 to 3.24.6
dependabot[bot] Mar 3, 2024
57ba8f5
test: fix flaky http-chunk-extensions-limit test
Ethan-Arrowood Mar 3, 2024
23c32ab
build: respect the `NODE` env variable in `Makefile`
aduh95 Mar 3, 2024
625c9e0
benchmark: update iterations of benchmark/domain/domain-fn-args.js
Mar 4, 2024
0dfe810
benchmark: update iterations of benchmark/async_hooks/async-local-
Mar 4, 2024
5864534
deps: update nghttp2 to 1.60.0
nodejs-github-bot Mar 5, 2024
fd86ea8
Revert "build: workaround for node-core-utils"
richardlau Mar 5, 2024
fff7f48
test: reduce flakiness of `test-runner-output`
aduh95 Mar 5, 2024
7ff3551
build: fix arm64 host cross-compilation in GN
zcbenz Feb 28, 2024
85aa6ca
Revert "test_runner: do not invoke after hook when test is empty"
cjihrig Mar 7, 2024
bee3b36
test: add regression test for test_runner after hook
cjihrig Mar 7, 2024
a48c9ca
stream: do not defer construction by one microtick
mcollina Mar 7, 2024
84c7e6f
2024-03-08, Version 21.7.1 (Current)
targos Mar 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: skip SEA tests when SEA generation fails
In the SEA tests, if any of these steps fail:

1. Copy the executable
2. Inject the SEA blob
3. Signing the SEA

We skip the test because the error likely comes from the system or
postject and is not something the Node.js core can fix. We only leave
an exception for a basic test that test injecting empty files as
SEA to ensure the workflow is working (but we still skip if copying
fails or signing fails on Windows).

PR-URL: #51887
Refs: #49630
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
joyeecheung authored and targos committed Mar 7, 2024
commit e992af81d358a486ba26cdc726f706354ba022bd
10 changes: 6 additions & 4 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1048,11 +1048,13 @@ Application functionality.
Skip the rest of the tests if single executable applications are not supported
in the current configuration.

### `injectAndCodeSign(targetExecutable, resource)`
### `generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow)`

Uses Postect to inject the contents of the file at the path `resource` into
the target executable file at the path `targetExecutable` and ultimately code
sign the final binary.
Copy `sourceExecutable` to `targetExecutable`, use postject to inject `seaBlob`
into `targetExecutable` and sign it if necessary.

If `verifyWorkflow` is false (default) and any of the steps fails,
it skips the tests. Otherwise, an error is thrown.

## tick Module

Expand Down
89 changes: 59 additions & 30 deletions test/common/sea.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
const common = require('../common');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
const { inspect } = require('util');

const { readFileSync } = require('fs');
const { readFileSync, copyFileSync } = require('fs');
const {
spawnSyncAndExitWithoutError,
} = require('../common/child_process');
Expand Down Expand Up @@ -54,47 +55,75 @@ function skipIfSingleExecutableIsNotSupported() {
}
}

function injectAndCodeSign(targetExecutable, resource) {
function generateSEA(targetExecutable, sourceExecutable, seaBlob, verifyWorkflow = false) {
try {
copyFileSync(sourceExecutable, targetExecutable);
} catch (e) {
const message = `Cannot copy ${sourceExecutable} to ${targetExecutable}: ${inspect(e)}`;
if (verifyWorkflow) {
throw new Error(message);
}
common.skip(message);
}
console.log(`Copied ${sourceExecutable} to ${targetExecutable}`);

const postjectFile = fixtures.path('postject-copy', 'node_modules', 'postject', 'dist', 'cli.js');
spawnSyncAndExitWithoutError(process.execPath, [
postjectFile,
targetExecutable,
'NODE_SEA_BLOB',
resource,
'--sentinel-fuse', 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2',
...process.platform === 'darwin' ? [ '--macho-segment-name', 'NODE_SEA' ] : [],
], {});
try {
spawnSyncAndExitWithoutError(process.execPath, [
postjectFile,
targetExecutable,
'NODE_SEA_BLOB',
seaBlob,
'--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)}`;
if (verifyWorkflow) {
throw new Error(message);
}
common.skip(message);
}
console.log(`Injected ${seaBlob} into ${targetExecutable}`);

if (process.platform === 'darwin') {
spawnSyncAndExitWithoutError('codesign', [ '--sign', '-', targetExecutable ], {});
spawnSyncAndExitWithoutError('codesign', [ '--verify', targetExecutable ], {});
try {
spawnSyncAndExitWithoutError('codesign', [ '--sign', '-', targetExecutable ], {});
spawnSyncAndExitWithoutError('codesign', [ '--verify', targetExecutable ], {});
} catch (e) {
const message = `Cannot sign ${targetExecutable}: ${inspect(e)}`;
if (verifyWorkflow) {
throw new Error(message);
}
common.skip(message);
}
console.log(`Signed ${targetExecutable}`);
} else if (process.platform === 'win32') {
let signtoolFound = false;
try {
spawnSyncAndExitWithoutError('where', [ 'signtool' ], {});
signtoolFound = true;
} catch (err) {
console.log(err.message);
}
if (signtoolFound) {
let certificatesFound = false;
let stderr;
try {
({ stderr } = spawnSyncAndExitWithoutError('signtool', [ 'sign', '/fd', 'SHA256', targetExecutable ], {}));
certificatesFound = true;
} catch (err) {
if (!/SignTool Error: No certificates were found that met all the given criteria/.test(stderr)) {
throw err;
}
} catch (e) {
const message = `Cannot find signtool: ${inspect(e)}`;
if (verifyWorkflow) {
throw new Error(message);
}
if (certificatesFound) {
spawnSyncAndExitWithoutError('signtool', 'verify', '/pa', 'SHA256', targetExecutable, {});
common.skip(message);
}
let stderr;
try {
({ stderr } = spawnSyncAndExitWithoutError('signtool', [ 'sign', '/fd', 'SHA256', targetExecutable ], {}));
spawnSyncAndExitWithoutError('signtool', 'verify', '/pa', 'SHA256', targetExecutable, {});
} catch (e) {
const message = `Cannot sign ${targetExecutable}: ${inspect(e)}\n${stderr}`;
if (verifyWorkflow) {
throw new Error(message);
}
common.skip(message);
}
console.log(`Signed ${targetExecutable}`);
}
}

module.exports = {
skipIfSingleExecutableIsNotSupported,
injectAndCodeSign,
generateSEA,
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const common = require('../common');

const {
injectAndCodeSign,
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');

Expand Down Expand Up @@ -56,8 +56,7 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);
generateSEA(outputFile, process.execPath, seaPrepBlob);

spawnSyncAndExitWithoutError(
outputFile,
Expand Down
5 changes: 2 additions & 3 deletions test/sequential/test-single-executable-application-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const common = require('../common');

const {
injectAndCodeSign,
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');

Expand Down Expand Up @@ -109,8 +109,7 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);
generateSEA(outputFile, process.execPath, seaPrepBlob);

spawnSyncAndExitWithoutError(
outputFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('../common');

const {
injectAndCodeSign,
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');

Expand Down Expand Up @@ -51,8 +51,7 @@ spawnSyncAndExitWithoutError(

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);
generateSEA(outputFile, process.execPath, seaPrepBlob);

spawnSyncAndExitWithoutError(
outputFile,
Expand Down
22 changes: 17 additions & 5 deletions test/sequential/test-single-executable-application-empty.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

require('../common');
const common = require('../common');

const {
injectAndCodeSign,
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');

Expand All @@ -13,7 +13,7 @@ skipIfSingleExecutableIsNotSupported();
// script.

const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs');
const { writeFileSync, existsSync } = require('fs');
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
const assert = require('assert');

Expand All @@ -38,8 +38,20 @@ spawnSyncAndExitWithoutError(

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);
// Verify the workflow.
try {
generateSEA(outputFile, process.execPath, seaPrepBlob, true);
} catch (e) {
if (/Cannot copy/.test(e.message)) {
common.skip(e.message);
} else if (common.isWindows) {
if (/Cannot sign/.test(e.message) || /Cannot find signtool/.test(e.message)) {
common.skip(e.message);
}
}

throw e;
}

spawnSyncAndExitWithoutError(
outputFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('../common');

const {
injectAndCodeSign,
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');

Expand All @@ -12,7 +12,7 @@ skipIfSingleExecutableIsNotSupported();
// This tests "useCodeCache" is ignored when "useSnapshot" is true.

const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs');
const { writeFileSync, existsSync } = require('fs');
const {
spawnSyncAndExitWithoutError
} = require('../common/child_process');
Expand Down Expand Up @@ -62,8 +62,7 @@ const outputFile = join(tmpdir.path, process.platform === 'win32' ? 'sea.exe' :

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);
generateSEA(outputFile, process.execPath, seaPrepBlob);

spawnSyncAndExitWithoutError(
outputFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('../common');

const {
injectAndCodeSign,
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');

Expand All @@ -12,7 +12,7 @@ skipIfSingleExecutableIsNotSupported();
// This tests the snapshot support in single executable applications.

const tmpdir = require('../common/tmpdir');
const { copyFileSync, writeFileSync, existsSync } = require('fs');
const { writeFileSync, existsSync } = require('fs');
const {
spawnSyncAndExit,
spawnSyncAndExitWithoutError
Expand Down Expand Up @@ -85,8 +85,7 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);
generateSEA(outputFile, process.execPath, seaPrepBlob);

spawnSyncAndExitWithoutError(
outputFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('../common');

const {
injectAndCodeSign,
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');

Expand Down Expand Up @@ -56,8 +56,7 @@ spawnSyncAndExitWithoutError(

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);
generateSEA(outputFile, process.execPath, seaPrepBlob);

spawnSyncAndExitWithoutError(
outputFile,
Expand Down
5 changes: 2 additions & 3 deletions test/sequential/test-single-executable-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('../common');

const {
injectAndCodeSign,
generateSEA,
skipIfSingleExecutableIsNotSupported,
} = require('../common/sea');

Expand Down Expand Up @@ -50,8 +50,7 @@ spawnSyncAndExitWithoutError(

assert(existsSync(seaPrepBlob));

copyFileSync(process.execPath, outputFile);
injectAndCodeSign(outputFile, seaPrepBlob);
generateSEA(outputFile, process.execPath, seaPrepBlob);

spawnSyncAndExitWithoutError(
outputFile,
Expand Down