From 9899c6659af12cbdf1ca5595c72bda57e042b280 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Fri, 20 Nov 2026 07:34:17 -0500 Subject: [PATCH] test(reverse): consolidate command outcome coverage (#12776) --- tests/composition/reverseEngineering.test.ts | 81 +------------------ .../reverseEngineeringCommandPort.test.ts | 7 +- 2 files changed, 5 insertions(+), 83 deletions(-) diff --git a/tests/composition/reverseEngineering.test.ts b/tests/composition/reverseEngineering.test.ts index 562787e1b8..8ece170156 100644 --- a/tests/composition/reverseEngineering.test.ts +++ b/tests/composition/reverseEngineering.test.ts @@ -1,9 +1,7 @@ -import { spawnFailure } from "../support/process/spawnFailure.js"; import { fileIdentity } from "../fixtures/evidenceSubject.js"; import { createHash } from "node:crypto"; import type { Stats } from "node:fs"; -import { mkdtemp, rm, writeFile } from "node:fs/promises"; -import { tmpdir } from "node:os"; +import { writeFile } from "node:fs/promises"; import { isAbsolute, join, relative, resolve } from "node:path"; import { PassThrough } from "node:stream"; @@ -154,60 +152,6 @@ describe("reverse engineering command services", () => { expect(result.value.subject?.local_path).toBe(path); }); - it("rejects non-regular artifacts without launching the provider", async () => { - const directory = await createTestTempDirectory( - "rea-reverse-special-file-", - ); - let invoked = false; - const service = new ReverseEngineeringService({ - runOwned: async () => { - invoked = true; - return ownedOutput(); - }, - }); - - const result = await service.inspectWithObjdump({ - path: directory, - operation: "file_headers", - }); - expect(result).toMatchObject({ - ok: false, - error: { - _tag: "AnalysisInputError", - operation: "inspect_with_objdump", - cause: { - code: "EINVAL", - message: "Artifact digest requires a regular file", - }, - }, - }); - expect(invoked).toBe(false); - }); - - it("classifies captured spawn failures instead of reporting provider evidence", async () => { - const directory = await createTestTempDirectory( - "rea-objdump-spawn-failure-", - ); - const path = join(directory, "fixture.bin"); - await writeFile(path, "fixture"); - const service = new ReverseEngineeringService({ - runOwned: async (spawn) => { - throw spawnFailure("ENOENT", spawn.command); - }, - }); - - const result = await service.inspectWithObjdump({ - path, - operation: "file_headers", - }); - expect(result.ok).toBe(false); - if (!result.ok) { - expect(result.error._tag).toBe("AnalysisCapabilityUnavailableError"); - expect(result.error.message).toContain("ENOENT"); - expect(result.error.message).not.toContain("stdout"); - } - }); - it("marks max-buffer termination as unknown completion while retaining output", async () => { const directory = await createTestTempDirectory("rea-objdump-max-buffer-"); const path = join(directory, "fixture.bin"); @@ -998,26 +942,3 @@ it("preserves provider facts when cancellation interrupts the post-run digest", }); } }); - -it("marks signal-terminated provider output incomplete", async () => { - const directory = await createTestTempDirectory("rea-rizin-signal-"); - const path = join(directory, "fixture.bin"); - await writeFile(path, "fixture"); - const service = new ReverseEngineeringService({ - runOwned: async () => { - throw ownedFailure( - "process", - ownedOutput("partial", "", { exitCode: null, signal: "SIGSEGV" }), - ); - }, - }); - - const result = await service.executeRizinCommand({ path, command: "iI" }); - expect(result.ok).toBe(true); - if (result.ok) - expect(result.value.raw_result).toMatchObject({ - signal: "SIGSEGV", - exit_code: null, - completion_status: "unknown", - }); -}); diff --git a/tests/composition/reverseEngineeringCommandPort.test.ts b/tests/composition/reverseEngineeringCommandPort.test.ts index 0176f0fb50..d91394fb3a 100644 --- a/tests/composition/reverseEngineeringCommandPort.test.ts +++ b/tests/composition/reverseEngineeringCommandPort.test.ts @@ -139,15 +139,16 @@ it("projects missing and non-file objdump targets with actionable path reasons", runOwned: run, }); - for (const [path, reason] of [ - [missing, "not found"], - [directory, "not a regular file"], + for (const [path, reason, code] of [ + [missing, "not found", "ENOENT"], + [directory, "not a regular file", "EINVAL"], ] as const) { const result = await service.inspectWithObjdump({ path, operation: "symbols", }); if (result.ok) throw new Error("Expected target validation failure"); + expect(result.error.cause).toMatchObject({ code }); const projection = projectAnalysisError(result.error); expect(analysisErrorProjectionSchema.safeParse(projection).success).toBe( true,