mirror of
https://github.com/morluto/rea.git
synced 2026-11-02 21:06:04 +00:00
* test: strengthen integration oracles and verification * test: bound lifecycle gates and strengthen workflow checks * test: verify complete paged and extracted results * test: preserve bytecode and cancellation evidence * test: strengthen retained evidence and fixture cleanup * test: require cross-projection bridge identities * test: retain fixture owners through cleanup failures * test: verify graph examples and project selectors * test: tighten provider and lifecycle regressions * test: consolidate hex coverage and bound cutter cleanup * test: bound subprocess output waits and strengthen graph checks * test: check mcp recovery and preserve cleanup owners * test: verify structured mcp argument failures * test: preserve artifact cleanup and gdb limit evidence * test: preserve evidence identities and bound provider gates * test: retain browser and comparison cleanup owners * test: bound startup and strengthen fixture oracles * test: bound lifecycle gates and verify recovered evidence * test: verify public outcomes and lifecycle ownership * test: assert precise evidence and release lifecycle gates * test: verify selected facts and bound cleanup waits * test: check retained evidence and decoded records * test: verify final reports and retain cleanup ownership * test: bound reviewed startup gates and retain cleanup * test: verify PE errors and preserve MCP cleanup * test: preserve MCP fixture cleanup ownership * test: release provider gates before late startup
75 lines
2.7 KiB
TypeScript
75 lines
2.7 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect } from "vitest";
|
|
|
|
import { elfNoteFixture } from "../../src/native/elf/ElfNotes.fixture.js";
|
|
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../support/cli/cliFixture.js";
|
|
|
|
const timingRecord = (stderr: string) => {
|
|
const lines = stderr.trim().split("\n");
|
|
expect(lines).toHaveLength(1);
|
|
const record: unknown = JSON.parse(lines[0]!);
|
|
expect(record).toMatchObject({
|
|
rea_timings: { version: 1, command_ms: expect.any(Number) },
|
|
});
|
|
const duration = (record as { rea_timings: { command_ms: number } })
|
|
.rea_timings.command_ms;
|
|
expect(Number.isFinite(duration)).toBe(true);
|
|
expect(duration).toBeGreaterThanOrEqual(0);
|
|
};
|
|
|
|
cliTest(
|
|
"writes opt-in command timing to stderr after success and failure without changing JSON stdout",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-cli-timings-");
|
|
const valid = join(root, "program");
|
|
const invalid = join(root, "truncated");
|
|
await writeFile(valid, elfNoteFixture({ ownership: "program" }));
|
|
await writeFile(invalid, Buffer.from("ELF"));
|
|
|
|
const defaultRun = await cli.run({
|
|
arguments: ["inspect-elf-notes", valid, "--json"],
|
|
});
|
|
expect(defaultRun.exitCode, defaultRun.stderr).toBe(0);
|
|
expect(defaultRun.stderr).not.toContain("rea_timings");
|
|
|
|
const successful = await cli.run({
|
|
arguments: ["--timings", "inspect-elf-notes", valid, "--json"],
|
|
});
|
|
expect(successful.exitCode, successful.stderr).toBe(0);
|
|
expect(successful.json).toMatchObject({
|
|
normalized_result: { coverage: { status: "complete" } },
|
|
});
|
|
expect(successful.stdout).toBe(defaultRun.stdout);
|
|
timingRecord(successful.stderr);
|
|
|
|
const defaultFailure = await cli.run({
|
|
arguments: ["inspect-elf-notes", invalid, "--json"],
|
|
});
|
|
expect(defaultFailure.exitCode).toBe(1);
|
|
const failed = await cli.run({
|
|
arguments: ["inspect-elf-notes", invalid, "--json", "--timings"],
|
|
});
|
|
expect(failed.exitCode).toBe(1);
|
|
expect(failed.json).toMatchObject({ code: "invalid_request" });
|
|
expect(failed.stdout).toBe(defaultFailure.stdout);
|
|
timingRecord(failed.stderr);
|
|
},
|
|
);
|
|
|
|
cliTest(
|
|
"preserves formatted root version output when timings are requested",
|
|
async ({ cli }) => {
|
|
const plain = await cli.run({ arguments: ["--version", "--json"] });
|
|
const timed = await cli.run({
|
|
arguments: ["--timings", "--version", "--json"],
|
|
});
|
|
expect(plain.exitCode).toBe(0);
|
|
expect(plain.json).toBeTypeOf("object");
|
|
expect(timed.exitCode).toBe(0);
|
|
expect(timed.stdout).toBe(plain.stdout);
|
|
expect(timed.stderr).toBe("");
|
|
},
|
|
);
|