Files
scriptc/tests/harness/libnode.ts
T
Malte UblandClaude Opus 5.5 75aa8509f6 Assemble libnode packs with NI-1's build-pack.mjs and run island tests in CI
Stack the libnode packs on the in-process loader (#1685) and use its
pack assembler and manifest format instead of a second one:
build-pack.mjs keeps its CLI and fields (schema, nodeVersion,
moduleVersion, bridgeAbi, platform, arch, files), adds the libnode and
bridge names, strips and (on macOS) re-signs the bridge and links it with
-z defs, and exports buildPack(), which the platform packs call with their
package, target and build inputs as extra manifest fields.

libnodeRecord falls back to the installed @scriptc/libnode-<platform>
pack, found from the entry's directory and then next to the compiler,
when neither --libnode nor SCRIPTC_LIBNODE names one.

The Linux test lanes restore the libnode build that the libnode-packs
workflow cached, assemble the linux-x64 pack from it in seconds
(build.mjs --from-cache never builds Node) and export SCRIPTC_LIBNODE, so
the Node island corpus and harness tests run instead of skipping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 17:52:22 -07:00

33 lines
1.3 KiB
TypeScript

/* Node island tests need a libnode pack (SCRIPTC_LIBNODE). The Linux x64 CI
* test lanes provide one (.github/actions/libnode-linux) and must run
* these tests, so there a missing pack is a failure, never a skip. Other
* CI platforms do not provision a pack yet, and a local run without a pack
* skips. */
import { readFileSync } from "node:fs";
/** `// @requires-libnode` in a corpus program's two-line directive head. */
export function requiresLibnode(file: string): boolean {
return readFileSync(file, "utf8")
.split("\n", 2)
.some((line) => /^\/\/ @requires-libnode\s*$/.test(line));
}
/** Whether CI must run the Node island tests on this machine. */
export const libnodeRequired =
process.env["CI"] !== undefined &&
process.env["CI"] !== "" &&
process.env["CI"] !== "false" &&
process.platform === "linux" &&
process.arch === "x64";
/** The configured pack, or null. Throws where CI requires one. */
export function libnodePack(): string | null {
const pack = process.env["SCRIPTC_LIBNODE"];
if (pack !== undefined && pack !== "") return pack;
if (libnodeRequired)
throw new Error(
"Node island tests need a libnode pack in this CI lane, and SCRIPTC_LIBNODE is not set (.github/actions/libnode-linux provides it)",
);
return null;
}