mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 11:13:21 +00:00
239 literal timeoutMs values on cli.run and processes.run only restated a guess at host speed. On hosted runners with four workers, cliOutput's 3-second value failed while the command still produced correct output. Deadlines that are the behavior under test, derived from an operation budget, or that bound a regression's wait remain. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
81 lines
2.8 KiB
TypeScript
81 lines
2.8 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { describe, expect } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
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",
|
|
REA_ANALYSIS_PROVIDER: "auto",
|
|
} as const;
|
|
|
|
const resultSchema = z.object({
|
|
subject: z.object({ format: z.string(), architecture: z.string() }),
|
|
normalized_result: z.record(z.string(), z.unknown()),
|
|
});
|
|
|
|
describe.skipIf(process.platform !== "darwin")(
|
|
"native Mach-O CLI with a thin arm64_32 object",
|
|
() => {
|
|
cliTest(
|
|
"admits the thin object for static Mach-O inspection",
|
|
async ({ cli, processes }) => {
|
|
const directory = await createTestTempDirectory(
|
|
"rea-native-cli-arm64-32-",
|
|
);
|
|
// A header-free source keeps the object independent of SDK slices.
|
|
const source = join(directory, "watch.c");
|
|
await writeFile(source, "int rea_watch_value(void) { return 42; }\n");
|
|
const object = join(directory, "watch.o");
|
|
const compiled = await processes.run("/usr/bin/xcrun", [
|
|
"clang",
|
|
"-arch",
|
|
"arm64_32",
|
|
"-c",
|
|
source,
|
|
"-o",
|
|
object,
|
|
]);
|
|
expect(compiled.exitCode, compiled.stderr).toBe(0);
|
|
for (const command of [
|
|
"list-architectures",
|
|
"inspect-macho",
|
|
"inspect-signature",
|
|
]) {
|
|
const result = await cli.run({
|
|
arguments: [command, object, "--json"],
|
|
environment,
|
|
});
|
|
expect(result.exitCode, `${command}: ${result.stdout}`).toBe(0);
|
|
const parsed = resultSchema.parse(result.json);
|
|
expect(parsed.subject).toMatchObject({
|
|
format: "mach-o",
|
|
architecture: "arm64_32",
|
|
});
|
|
if (command === "list-architectures")
|
|
expect(
|
|
listArchitecturesSchema.shape.architectures
|
|
.parse(parsed.normalized_result.architectures)
|
|
.items.map(({ name }) => name),
|
|
).toEqual(["arm64_32"]);
|
|
}
|
|
// 32-bit dispatch metadata is unsupported, and no deep-analysis
|
|
// provider admits arm64_32, so the fallback is a typed refusal.
|
|
const dispatch = await cli.run({
|
|
arguments: ["inspect-native-dispatch-metadata", object, "--json"],
|
|
environment,
|
|
});
|
|
expect(dispatch.json).toMatchObject({
|
|
code: "capability_unavailable",
|
|
retryable: false,
|
|
details: { selection_reason: "target_unsupported" },
|
|
});
|
|
},
|
|
);
|
|
},
|
|
);
|