mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 05:32:44 +00:00
* test: own temporary directories through createTestTempDirectory in remaining tests/ Give per-test directories in the remaining tests/ suites to createTestTempDirectory so onTestFinished removes them through removeTestWorkspace. Keep suite-scoped roots and child-process directories whose removal is the assertion. * test: drop empty cleanup callbacks and keep the capture skip reason visible Remove the no-op withVerifierCleanup steps left after directory removal moved to createTestTempDirectory. Put the native capture skip explanation in the Linux sample test name, because it.skipIf only tests truthiness. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
72 lines
2.8 KiB
TypeScript
72 lines
2.8 KiB
TypeScript
import { chmod, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { captureProcessScenarioFile } from "../../../src/application/process/ProcessCli.js";
|
|
import { isCliOperationFailure } from "../../../src/cliLogging.js";
|
|
import { createDirectAnalysis } from "../../../src/composition/directAnalysis.js";
|
|
import { probeProcessCaptureCapability } from "../../../src/process/capture/ProcessCaptureCapability.js";
|
|
import { parseEvidence } from "../../../src/domain/evidence.js";
|
|
import { parseProcessCapture } from "../../../src/domain/process/processCaptureParsing.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
describe("the CLI takes its environment as an input", () => {
|
|
it("resolves from injected PATH and inherits injected env with scenario overrides", async ({
|
|
skip,
|
|
}) => {
|
|
const capability = await probeProcessCaptureCapability();
|
|
if (!capability.available) {
|
|
skip("Process capture is unavailable on this host");
|
|
return;
|
|
}
|
|
|
|
const root = await createTestTempDirectory("rea-cli-env-process-");
|
|
const bin = join(root, "bin");
|
|
const executable = join(bin, "rea-injected-process-probe");
|
|
const scenarioPath = join(root, "scenario.json");
|
|
await mkdir(bin);
|
|
await writeFile(
|
|
executable,
|
|
[
|
|
"#!/bin/sh",
|
|
'printf "%s|%s\\n" "$REA_CAPTURE_INJECTED_MARKER" "$REA_CAPTURE_SCENARIO_OVERRIDE"',
|
|
].join("\n"),
|
|
);
|
|
await chmod(executable, 0o755);
|
|
await writeFile(
|
|
scenarioPath,
|
|
JSON.stringify({
|
|
executable: "rea-injected-process-probe",
|
|
working_directory: root,
|
|
environment: { REA_CAPTURE_SCENARIO_OVERRIDE: "scenario-value" },
|
|
}),
|
|
);
|
|
|
|
const result = await captureProcessScenarioFile(scenarioPath, {
|
|
PATH: bin,
|
|
REA_CAPTURE_INJECTED_MARKER: "injected-value",
|
|
REA_CAPTURE_SCENARIO_OVERRIDE: "host-value",
|
|
});
|
|
if (isCliOperationFailure(result))
|
|
throw new Error(
|
|
`Process capture returned an error: ${JSON.stringify(result)}`,
|
|
);
|
|
const evidence = parseEvidence(result);
|
|
const capture = parseProcessCapture(evidence.normalized_result);
|
|
expect(capture.frames.map(({ data }) => data).join("")).toContain(
|
|
"injected-value|scenario-value",
|
|
);
|
|
});
|
|
|
|
it("reports session status from a supplied environment", async () => {
|
|
// An invalid configuration must surface through the caller's supplied
|
|
// environment rather than whatever the process happens to carry.
|
|
const result = await createDirectAnalysis({
|
|
REA_LOG_LEVEL: "not-a-level",
|
|
}).runSessionStatus();
|
|
expect(result).toMatchObject({ error: expect.anything() });
|
|
});
|
|
});
|