fix(test): use direct Node launcher on macOS

This commit is contained in:
morluto 2026-07-24 03:31:26 +00:00
parent 42fbbb297b
commit 13f3372a8b
3 changed files with 52 additions and 2 deletions

View File

@ -0,0 +1,26 @@
export interface PackageHopperEnvironment {
readonly HOPPER_LAUNCHER_PATH: string;
readonly HOPPER_LOADER_ARGS_JSON: string;
}
export function packageHopperEnvironment(
root: string,
platform?: string,
): PackageHopperEnvironment;
export function verifyPackageEnvironment(input: {
readonly root: string;
readonly workspace: string;
readonly evidenceRoot: string;
readonly referenceRoot: string;
}): Promise<{
readonly prefix: string;
readonly home: string;
readonly npxLog: string;
readonly claudeConfig: string;
readonly codexConfig: string;
readonly codexTarget: string;
readonly cursorConfig: string;
readonly cursorTarget: string;
readonly environment: Readonly<Record<string, string | undefined>>;
}>;

View File

@ -92,9 +92,9 @@ export async function verifyPackageEnvironment({
};
}
const packageHopperEnvironment = (root) => {
export const packageHopperEnvironment = (root, platform = process.platform) => {
const fakeLauncher = join(root, "tests/fixtures/fakeLauncher.mjs");
if (process.platform === "win32")
if (platform !== "linux")
return {
HOPPER_LAUNCHER_PATH: process.execPath,
HOPPER_LOADER_ARGS_JSON: JSON.stringify([fakeLauncher]),

View File

@ -1,5 +1,6 @@
import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
import { packageHopperEnvironment } from "../scripts/verify-package-environment.mjs";
describe("package installation workflows", () => {
it("runs package E2E without the retired native rebuild script", async () => {
@ -77,4 +78,27 @@ describe("package installation workflows", () => {
expect(canary).toContain('mkdtemp(join(tmpdir(), "rea-published-canary-")');
expect(canary).toContain("cwd: canaryRoot");
});
it("uses direct Node ownership on macOS and Windows", () => {
const root = "/tmp/rea-package";
const expected = {
HOPPER_LAUNCHER_PATH: process.execPath,
HOPPER_LOADER_ARGS_JSON: JSON.stringify([
`${root}/tests/fixtures/fakeLauncher.mjs`,
]),
};
expect(packageHopperEnvironment(root, "darwin")).toEqual(expected);
expect(packageHopperEnvironment(root, "win32")).toEqual(expected);
expect(packageHopperEnvironment(root, "linux")).toEqual({
HOPPER_LAUNCHER_PATH: "/bin/sh",
HOPPER_LOADER_ARGS_JSON: JSON.stringify([
"-c",
'node_path=$1; shift; "$node_path" "$@"',
"rea-package-hopper",
process.execPath,
`${root}/tests/fixtures/fakeLauncher.mjs`,
]),
});
});
});