mirror of
https://github.com/morluto/rea.git
synced 2026-11-13 18:22:42 +00:00
Refs #4522, #4526, #4555. Retain producer-owned compiler output and cleanup markers through xcrun resolution and native failure projection. Keep physical preparation failures primary and preserve separate command deadline classification for interrupted preparation. Omitted output facts stay unknown; client close does not resolve foreign helper cleanup. Include CLI failure output in native regression reports. Validation: 87 focused tests passed. Broader 140-file run passed 1483 tests, skipped 109, and exposed three pre-existing deep-provider selection failures tracked in #4555. Static checks passed. Compiler faults use controlled Node fixtures; native Swift compiler faults and Windows execution were not verified. Other command consumers still need preparation-fact propagation.
58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import { join } from "node:path";
|
|
import { writeFile } from "node:fs/promises";
|
|
|
|
import { describe, expect } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
import { inspectMachoSchema } from "../../../src/domain/native/nativeInspection.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../../support/cli/cliFixture.js";
|
|
|
|
const evidenceSchema = z.object({ normalized_result: inspectMachoSchema });
|
|
|
|
describe.skipIf(process.platform !== "darwin")(
|
|
"native Mach-O CLI dylib identity",
|
|
() => {
|
|
cliTest(
|
|
"keeps a dylib's own install name out of its dependencies",
|
|
async ({ cli, processes }) => {
|
|
const directory = await createTestTempDirectory("rea-dylib-identity-");
|
|
const source = join(directory, "library.c");
|
|
const library = join(directory, "libprobe.dylib");
|
|
await writeFile(source, "int exported_value(void) { return 42; }\n");
|
|
const compiled = await processes.run(
|
|
"/usr/bin/xcrun",
|
|
[
|
|
"clang",
|
|
"-dynamiclib",
|
|
source,
|
|
"-Wl,-install_name,@rpath/libprobe.dylib",
|
|
"-o",
|
|
library,
|
|
],
|
|
{ timeoutMs: 30_000 },
|
|
);
|
|
expect(compiled.exitCode, compiled.stderr).toBe(0);
|
|
const result = await cli.run({
|
|
arguments: ["inspect-macho", library, "--json"],
|
|
environment: { REA_LOG_LEVEL: "silent" },
|
|
});
|
|
expect(result.exitCode, result.stdout + result.stderr).toBe(0);
|
|
const inspected = evidenceSchema.parse(result.json).normalized_result;
|
|
expect(inspected.dependencies).toMatchObject({
|
|
items: [
|
|
{ path: "/usr/lib/libSystem.B.dylib", kind: "LC_LOAD_DYLIB" },
|
|
],
|
|
total: 1,
|
|
exhaustive: true,
|
|
});
|
|
expect(
|
|
inspected.load_commands.items.find(
|
|
({ kind }) => kind === "LC_ID_DYLIB",
|
|
)?.fields.name,
|
|
).toBe("@rpath/libprobe.dylib (offset 24)");
|
|
},
|
|
);
|
|
},
|
|
);
|