Files
reverse-engineering-anything/src/native/NativeMachoCommandDiagnostics.test.ts
T
morlutoandCursor Agent 5821506eb2 fix(native): preserve Mach-O source and decode facts (#9902)
* fix(native): retain Mach-O file identity through completion

* fix(native): distinguish malformed Mach-O encryption facts

* fix(native): preserve Mach-O command and dylib coverage

* fix(native): preserve Apple dispatch fixup and declaration facts

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-10 22:50:26 -05:00

35 lines
1.1 KiB
TypeScript

import { expect, it } from "vitest";
import type { NativeCommandCapture } from "./CommandRunner.js";
import { parseDyldFileTypeRefusal } from "./NativeMachoCommandDiagnostics.js";
const capture = (stdout: string, stderr = ""): NativeCommandCapture => ({
tool: "dyld_info",
executable: "/usr/bin/dyld_info",
executableSha256: "a".repeat(64),
toolVersion: null,
versionReason: null,
arguments: ["-imports", "/selected/target"],
stdout,
stderr,
stdoutBytes: Buffer.byteLength(stdout),
stderrBytes: Buffer.byteLength(stderr),
exitCode: 1,
signal: null,
});
it.each([
["unknown filetype 3", "3"],
["unknown mh.filetype 4", "4"],
])("recognizes a sole dyld file-type refusal (%s)", (diagnostic, fileType) => {
expect(
parseDyldFileTypeRefusal(capture(`/selected/target:\n${diagnostic}\n`)),
).toEqual({ fileType, diagnostic });
});
it.each([
["unknown mh.filetype 4\nmalformed load command\n", ""],
["unknown mh.filetype 4\n", "read failed\n"],
])("keeps mixed dyld diagnostics unclassified (%s, %s)", (stdout, stderr) => {
expect(parseDyldFileTypeRefusal(capture(stdout, stderr))).toBeNull();
});