Files
reverse-engineering-anything/tests/boundary/cli/foreignUniversalMachoCli.test.ts
T
46728ca41d test: remove per-test deadlines owned by project policy
Explicit deadlines at or below the project deadline only shortened it:
a literal 30-second value also disabled the coverage scaling, which timed
out wide-capacity regressions on main. Workloads above the built
deadline use the long-running tag. Deadlines derived from an operation
budget remain.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 05:27:07 +08:00

90 lines
2.9 KiB
TypeScript

import { writeFile } from "node:fs/promises";
import { join, resolve } from "node:path";
import { expect } from "vitest";
import { z } from "zod";
import { fat } from "../../../src/domain/binaryTarget.fixture.js";
import { listArchitecturesSchema } from "../../../src/domain/native/nativeInspection.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
const environment = { REA_LOG_LEVEL: "silent" } as const;
// The one slice of each container below is never the host's architecture.
const foreign =
process.arch === "arm64"
? { name: "x86_64", cpuType: 0x01000007 }
: { name: "arm64", cpuType: 0x0100000c };
cliTest.skipIf(process.platform !== "darwin")(
"inventories a universal Mach-O whose only slice is foreign to the host",
async ({ cli, processes }) => {
const directory = await createTestTempDirectory("rea-foreign-fat-cli-");
const thin = join(directory, "thin");
const universal = join(directory, "universal");
const compiled = await processes.run(
"/usr/bin/xcrun",
[
"clang",
"-arch",
foreign.name,
resolve("tests/conformance/c/fixture.c"),
"-o",
thin,
],
{ timeoutMs: 30_000 },
);
expect(compiled.exitCode, compiled.stderr).toBe(0);
const created = await processes.run(
"/usr/bin/xcrun",
["lipo", "-create", thin, "-output", universal],
{ timeoutMs: 30_000 },
);
expect(created.exitCode, created.stderr).toBe(0);
const result = await cli.run({
arguments: ["list-architectures", universal, "--json"],
environment,
});
expect(result.exitCode, result.stderr).toBe(0);
const evidence = z
.object({
subject: z.object({ format: z.string() }),
normalized_result: listArchitecturesSchema,
})
.parse(result.json);
expect(evidence.subject.format).toBe("mach-o-universal");
expect(evidence.normalized_result.architectures).toMatchObject({
total: 1,
exhaustive: true,
items: [{ name: foreign.name }],
});
expect(
evidence.normalized_result.architectures.items[0]?.file_offset,
).toBeGreaterThan(0);
},
);
cliTest.skipIf(process.platform === "darwin")(
"admits a universal Mach-O whose only slice is foreign to the host",
async ({ cli }) => {
const directory = await createTestTempDirectory("rea-foreign-fat-cli-");
const universal = join(directory, "universal");
await writeFile(universal, fat([foreign.cpuType]));
const result = await cli.run({
arguments: ["list-architectures", universal, "--json"],
environment,
});
// The target is admitted; only the macOS-only lipo inventory is refused.
expect(result.exitCode).not.toBe(0);
expect(result.json).toMatchObject({
code: "capability_unavailable",
details: { provider_id: "native-macos", operation: "list_architectures" },
});
},
);