test: remove duplicate result assertions before throwing guards
This commit is contained in:
@@ -139,7 +139,6 @@ describe("analysis provider registry: binding failures and cancellation", () =>
|
|||||||
const unsupported = await new AnalysisProviderRegistry([
|
const unsupported = await new AnalysisProviderRegistry([
|
||||||
candidate("alpha", { available: false }).provider,
|
candidate("alpha", { available: false }).provider,
|
||||||
]).select(ARTIFACT_TARGET, "alpha");
|
]).select(ARTIFACT_TARGET, "alpha");
|
||||||
expect(unsupported.ok).toBe(false);
|
|
||||||
if (unsupported.ok)
|
if (unsupported.ok)
|
||||||
throw new Error("expected unsupported target rejection");
|
throw new Error("expected unsupported target rejection");
|
||||||
expect(unsupported.error).toBeInstanceOf(ProviderSelectionError);
|
expect(unsupported.error).toBeInstanceOf(ProviderSelectionError);
|
||||||
@@ -181,7 +180,6 @@ describe("analysis provider registry: binding failures and cancellation", () =>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
const explicit = await automatic.select(ARTIFACT_TARGET, "alpha");
|
const explicit = await automatic.select(ARTIFACT_TARGET, "alpha");
|
||||||
expect(explicit.ok).toBe(false);
|
|
||||||
if (explicit.ok) throw new Error("expected provider selection rejection");
|
if (explicit.ok) throw new Error("expected provider selection rejection");
|
||||||
expect(explicit.error).toBeInstanceOf(ProviderSelectionError);
|
expect(explicit.error).toBeInstanceOf(ProviderSelectionError);
|
||||||
if (explicit.error instanceof ProviderSelectionError)
|
if (explicit.error instanceof ProviderSelectionError)
|
||||||
@@ -213,7 +211,6 @@ describe("analysis provider registry: binding failures and cancellation", () =>
|
|||||||
const explicit = await new AnalysisProviderRegistry([
|
const explicit = await new AnalysisProviderRegistry([
|
||||||
failed.provider,
|
failed.provider,
|
||||||
]).select(DATABASE_TARGET, "failed");
|
]).select(DATABASE_TARGET, "failed");
|
||||||
expect(explicit.ok).toBe(false);
|
|
||||||
if (explicit.ok) throw new Error("expected provider selection rejection");
|
if (explicit.ok) throw new Error("expected provider selection rejection");
|
||||||
expect(explicit.error).toBeInstanceOf(ProviderSelectionError);
|
expect(explicit.error).toBeInstanceOf(ProviderSelectionError);
|
||||||
if (explicit.error instanceof ProviderSelectionError)
|
if (explicit.error instanceof ProviderSelectionError)
|
||||||
|
|||||||
@@ -230,7 +230,6 @@ describe("analysis snapshot cache partitioning", () => {
|
|||||||
ANALYSIS_SNAPSHOT_PROFILE,
|
ANALYSIS_SNAPSHOT_PROFILE,
|
||||||
createEvidenceBundle([evidence]),
|
createEvidenceBundle([evidence]),
|
||||||
);
|
);
|
||||||
expect(exported.ok).toBe(true);
|
|
||||||
if (!exported.ok) throw new Error("snapshot export failed");
|
if (!exported.ok) throw new Error("snapshot export failed");
|
||||||
const tampered = structuredClone(exported.value);
|
const tampered = structuredClone(exported.value);
|
||||||
const tamperedEntry = tampered.entries[0];
|
const tamperedEntry = tampered.entries[0];
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ describe("JavaScript analysis cancellation before publication", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(requested).toBe(true);
|
expect(requested).toBe(true);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok)
|
if (result.ok)
|
||||||
throw new Error("Cancelled analysis must not publish Evidence");
|
throw new Error("Cancelled analysis must not publish Evidence");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
@@ -68,7 +67,6 @@ describe("JavaScript analysis cancellation before publication", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected cancellation before admission");
|
if (result.ok) throw new Error("Expected cancellation before admission");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
details: { reason: "cancelled" },
|
details: { reason: "cancelled" },
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ describe("JavaScript application failure diagnostics", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected analysis failure");
|
if (result.ok) throw new Error("Expected analysis failure");
|
||||||
expect(result.error.cause).toBe(cause);
|
expect(result.error.cause).toBe(cause);
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
@@ -59,7 +58,6 @@ describe("JavaScript application failure diagnostics", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected analysis failure");
|
if (result.ok) throw new Error("Expected analysis failure");
|
||||||
expect(result.error.cause).toBe(cause);
|
expect(result.error.cause).toBe(cause);
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
@@ -84,7 +82,6 @@ describe("JavaScript application failure diagnostics", () => {
|
|||||||
input_path: join(root, "missing"),
|
input_path: join(root, "missing"),
|
||||||
format: "directory",
|
format: "directory",
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected missing artifact failure");
|
if (result.ok) throw new Error("Expected missing artifact failure");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
code: "artifact_operation_failed",
|
code: "artifact_operation_failed",
|
||||||
@@ -107,7 +104,6 @@ describe("JavaScript application failure diagnostics", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected analysis failure");
|
if (result.ok) throw new Error("Expected analysis failure");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
code: "execution_failure",
|
code: "execution_failure",
|
||||||
@@ -140,7 +136,6 @@ describe("JavaScript application failure diagnostics", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected analysis failure");
|
if (result.ok) throw new Error("Expected analysis failure");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
code: "execution_failure",
|
code: "execution_failure",
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ describe("source-relative file URL paths", () => {
|
|||||||
input_path: root,
|
input_path: root,
|
||||||
format: "directory",
|
format: "directory",
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
|
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
|
||||||
result.value.normalized_result,
|
result.value.normalized_result,
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ describe("ESM module URL decoding", () => {
|
|||||||
input_path: root,
|
input_path: root,
|
||||||
format: "directory",
|
format: "directory",
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
|
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
|
||||||
result.value.normalized_result,
|
result.value.normalized_result,
|
||||||
@@ -235,7 +234,6 @@ describe("package exports URL paths", () => {
|
|||||||
input_path: root,
|
input_path: root,
|
||||||
format: "directory",
|
format: "directory",
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
|
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
|
||||||
result.value.normalized_result,
|
result.value.normalized_result,
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ describe("JavaScript recovery workflow", () => {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
const result = await service.recover(input);
|
const result = await service.recover(input);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected invalid port output");
|
if (result.ok) throw new Error("expected invalid port output");
|
||||||
expect(result.error._tag).toBe("AnalysisOutputError");
|
expect(result.error._tag).toBe("AnalysisOutputError");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -198,7 +198,6 @@ describe("PlaywrightBrowserScenarioProvider", () => {
|
|||||||
const result = await provider.captureScenario(
|
const result = await provider.captureScenario(
|
||||||
scenario({ events: ["frames"] }),
|
scenario({ events: ["frames"] }),
|
||||||
);
|
);
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
expect(result.value.completeness).toMatchObject({
|
expect(result.value.completeness).toMatchObject({
|
||||||
status: "incomplete",
|
status: "incomplete",
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ describe("runtime configuration", () => {
|
|||||||
describe("runtime target configuration", () => {
|
describe("runtime target configuration", () => {
|
||||||
it("rejects invalid target kinds with actionable environment diagnostics", () => {
|
it("rejects invalid target kinds with actionable environment diagnostics", () => {
|
||||||
const result = parseConfig({ HOPPER_TARGET_KIND: "archive" });
|
const result = parseConfig({ HOPPER_TARGET_KIND: "archive" });
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected invalid target kind");
|
if (result.ok) throw new Error("Expected invalid target kind");
|
||||||
expect(result.error.message).toContain("Invalid REA environment");
|
expect(result.error.message).toContain("Invalid REA environment");
|
||||||
});
|
});
|
||||||
@@ -121,7 +120,6 @@ describe("runtime collection configuration", () => {
|
|||||||
HOPPER_TARGET_PATH: "/tmp/a",
|
HOPPER_TARGET_PATH: "/tmp/a",
|
||||||
HOPPER_LOADER_ARGS_JSON: encoded,
|
HOPPER_LOADER_ARGS_JSON: encoded,
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok)
|
if (result.ok)
|
||||||
throw new Error("expected malformed loader arguments to fail");
|
throw new Error("expected malformed loader arguments to fail");
|
||||||
expect(result.error.message).toContain(
|
expect(result.error.message).toContain(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { safeParseJson } from "./safeJson.js";
|
|||||||
it("keeps the original JSON parse failure as the cause", () => {
|
it("keeps the original JSON parse failure as the cause", () => {
|
||||||
const parsed = safeParseJson("{");
|
const parsed = safeParseJson("{");
|
||||||
|
|
||||||
expect(parsed.ok).toBe(false);
|
|
||||||
if (parsed.ok) throw new Error("expected invalid JSON to fail");
|
if (parsed.ok) throw new Error("expected invalid JSON to fail");
|
||||||
expect(parsed.error).toContain("JSON");
|
expect(parsed.error).toContain("JSON");
|
||||||
expect(parsed.cause).toBeInstanceOf(SyntaxError);
|
expect(parsed.cause).toBeInstanceOf(SyntaxError);
|
||||||
|
|||||||
@@ -185,7 +185,6 @@ describe("Ghidra jump-table mapping contract", () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(parsed.ok).toBe(true);
|
|
||||||
if (!parsed.ok) throw parsed.error;
|
if (!parsed.ok) throw parsed.error;
|
||||||
const output = functionDossierSchema.parse(parsed.value).native_api;
|
const output = functionDossierSchema.parse(parsed.value).native_api;
|
||||||
if (output?.available !== true)
|
if (output?.available !== true)
|
||||||
@@ -218,7 +217,6 @@ describe("Ghidra jump-table mapping contract", () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(parsed.ok).toBe(true);
|
|
||||||
if (!parsed.ok) throw parsed.error;
|
if (!parsed.ok) throw parsed.error;
|
||||||
expect(functionDossierSchema.parse(parsed.value).native_api).toMatchObject({
|
expect(functionDossierSchema.parse(parsed.value).native_api).toMatchObject({
|
||||||
jump_tables: [{ default_targets: [], mappings: [{ case_value: null }] }],
|
jump_tables: [{ default_targets: [], mappings: [{ case_value: null }] }],
|
||||||
|
|||||||
@@ -428,7 +428,6 @@ describe("Ghidra client projection", () => {
|
|||||||
executableTarget("elf", "x86_64"),
|
executableTarget("elf", "x86_64"),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(resolved.ok).toBe(true);
|
|
||||||
if (!resolved.ok) throw resolved.error;
|
if (!resolved.ok) throw resolved.error;
|
||||||
if (resolved.value.profile === null)
|
if (resolved.value.profile === null)
|
||||||
throw new Error("Expected a bound Ghidra profile");
|
throw new Error("Expected a bound Ghidra profile");
|
||||||
|
|||||||
@@ -163,7 +163,6 @@ describe("attached IDA function observations", () => {
|
|||||||
const result = await client.execute("analyze_function", {
|
const result = await client.execute("analyze_function", {
|
||||||
procedure: "0x1004",
|
procedure: "0x1004",
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
const dossier = functionDossierSchema.parse(result.value.result);
|
const dossier = functionDossierSchema.parse(result.value.result);
|
||||||
expect(dossier.procedure.address).toBe("0x1000");
|
expect(dossier.procedure.address).toBe("0x1000");
|
||||||
@@ -367,7 +366,6 @@ describe("headless IDA session ownership and cleanup", () => {
|
|||||||
const result = await client.execute("analyze_function", {
|
const result = await client.execute("analyze_function", {
|
||||||
procedure: "main",
|
procedure: "main",
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
expect(producer.inputPath).not.toBe(target.path);
|
expect(producer.inputPath).not.toBe(target.path);
|
||||||
expect(await readFile(producer.inputPath)).toEqual(original);
|
expect(await readFile(producer.inputPath)).toEqual(original);
|
||||||
|
|||||||
@@ -500,7 +500,6 @@ it("fails closed on Windows before resolving or launching scenario paths", async
|
|||||||
working_directory: "Z:/missing/working-directory",
|
working_directory: "Z:/missing/working-directory",
|
||||||
});
|
});
|
||||||
const result = await captureProcessScenario(scenario, undefined, "win32");
|
const result = await captureProcessScenario(scenario, undefined, "win32");
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected Windows ownership refusal");
|
if (result.ok) throw new Error("expected Windows ownership refusal");
|
||||||
if (!(result.error instanceof AnalysisCapabilityUnavailableError))
|
if (!(result.error instanceof AnalysisCapabilityUnavailableError))
|
||||||
throw new Error("expected a capability-unavailable outcome");
|
throw new Error("expected a capability-unavailable outcome");
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ describe("MCP result encoding budget", () => {
|
|||||||
{ result: "x".repeat(8191) + "😀" + '中文\n"'.repeat(20000) },
|
{ result: "x".repeat(8191) + "😀" + '中文\n"'.repeat(20000) },
|
||||||
])("counts actual UTF-8 structured and escaped text bytes", (candidate) => {
|
])("counts actual UTF-8 structured and escaped text bytes", (candidate) => {
|
||||||
const encoded = encodeToolResult(candidate);
|
const encoded = encodeToolResult(candidate);
|
||||||
expect(encoded.ok).toBe(true);
|
|
||||||
if (!encoded.ok) throw new Error("Expected complete encoding");
|
if (!encoded.ok) throw new Error("Expected complete encoding");
|
||||||
expect(encoded.text).toBe(JSON.stringify(candidate));
|
expect(encoded.text).toBe(JSON.stringify(candidate));
|
||||||
expect(encoded.bytes).toBe(
|
expect(encoded.bytes).toBe(
|
||||||
|
|||||||
@@ -216,7 +216,6 @@ it("retains APK identity, original input, raw producer data and normalized obser
|
|||||||
const outcome = await service.execute("inspect_android_package", {
|
const outcome = await service.execute("inspect_android_package", {
|
||||||
path: apk,
|
path: apk,
|
||||||
});
|
});
|
||||||
expect(outcome.ok).toBe(true);
|
|
||||||
if (!outcome.ok) throw outcome.error;
|
if (!outcome.ok) throw outcome.error;
|
||||||
const result = androidResultSchemas.inspect_android_package.parse(
|
const result = androidResultSchemas.inspect_android_package.parse(
|
||||||
outcome.value.normalized_result,
|
outcome.value.normalized_result,
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ describe("CDP target inventory", () => {
|
|||||||
allowed_origins: ["https://allowed.example"],
|
allowed_origins: ["https://allowed.example"],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
expect(result.value.targets).toHaveLength(targets.length);
|
expect(result.value.targets).toHaveLength(targets.length);
|
||||||
expect(result.value.targets[0]?.target_id).toBe("target-0000");
|
expect(result.value.targets[0]?.target_id).toBe("target-0000");
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ describe("CdpBrowserProvider navigation timeline", () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
expect(result.value.timeline).toHaveLength(additionalEvents + 6);
|
expect(result.value.timeline).toHaveLength(additionalEvents + 6);
|
||||||
expect(result.value.completeness.truncated_sections).not.toContain(
|
expect(result.value.completeness.truncated_sections).not.toContain(
|
||||||
|
|||||||
@@ -281,7 +281,6 @@ describe("runtime lifecycle and invalid producer data", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok)
|
if (result.ok)
|
||||||
throw new Error("Cancellation must not produce successful evidence");
|
throw new Error("Cancellation must not produce successful evidence");
|
||||||
expect(result.error._tag).toBe("AnalysisCancelledError");
|
expect(result.error._tag).toBe("AnalysisCancelledError");
|
||||||
@@ -297,7 +296,6 @@ describe("runtime lifecycle and invalid producer data", () => {
|
|||||||
unsupportedMethods: ["Profiler.stopPreciseCoverage"],
|
unsupportedMethods: ["Profiler.stopPreciseCoverage"],
|
||||||
});
|
});
|
||||||
const result = await provider.observeExecution(execution);
|
const result = await provider.observeExecution(execution);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Failed cleanup must not return success");
|
if (result.ok) throw new Error("Failed cleanup must not return success");
|
||||||
expect(result.error.cleanupIncomplete).toBe(true);
|
expect(result.error.cleanupIncomplete).toBe(true);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -523,7 +523,6 @@ describe("iOS-style app bundle targets", () => {
|
|||||||
await chmod(wrapper, 0o000);
|
await chmod(wrapper, 0o000);
|
||||||
try {
|
try {
|
||||||
const result = await parseBinaryTarget(app, directory, "arm64");
|
const result = await parseBinaryTarget(app, directory, "arm64");
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected a permission denial");
|
if (result.ok) throw new Error("Expected a permission denial");
|
||||||
expect(result.error.message).toContain("permission denied");
|
expect(result.error.message).toContain("permission denied");
|
||||||
} finally {
|
} finally {
|
||||||
@@ -564,7 +563,6 @@ describe("iOS-style app bundle targets", () => {
|
|||||||
await writeFile(join(app, "Info.plist"), plist("Escaping"));
|
await writeFile(join(app, "Info.plist"), plist("Escaping"));
|
||||||
await symlink(outside, join(app, "Escaping"));
|
await symlink(outside, join(app, "Escaping"));
|
||||||
const result = await parseBinaryTarget(app, directory, "arm64");
|
const result = await parseBinaryTarget(app, directory, "arm64");
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected an escaping program file");
|
if (result.ok) throw new Error("Expected an escaping program file");
|
||||||
expect(result.error.message).toContain("leaves the bundle root");
|
expect(result.error.message).toContain("leaves the bundle root");
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -337,7 +337,6 @@ describe("reference source import behavior", () => {
|
|||||||
message: "fixture",
|
message: "fixture",
|
||||||
});
|
});
|
||||||
const result = await importTree(root);
|
const result = await importTree(root);
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw result.error;
|
if (!result.ok) throw result.error;
|
||||||
expect(result.value.vcs).toEqual({ kind: "git", head: oid, dirty: null });
|
expect(result.value.vcs).toEqual({ kind: "git", head: oid, dirty: null });
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ describe("captured script publication failures and cleanup", () => {
|
|||||||
const { input } = await setup();
|
const { input } = await setup();
|
||||||
await writeFile(input.capture_path, bytes);
|
await writeFile(input.capture_path, bytes);
|
||||||
const result = await exportWebScripts(input);
|
const result = await exportWebScripts(input);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected invalid input");
|
if (result.ok) throw new Error("Expected invalid input");
|
||||||
expect(result.error._tag).toBe("AnalysisInputError");
|
expect(result.error._tag).toBe("AnalysisInputError");
|
||||||
await expect(access(input.output_directory)).rejects.toMatchObject({
|
await expect(access(input.output_directory)).rejects.toMatchObject({
|
||||||
@@ -195,7 +194,6 @@ describe("captured script publication failures and cleanup", () => {
|
|||||||
process.platform === "win32" ? "junction" : "dir",
|
process.platform === "win32" ? "junction" : "dir",
|
||||||
);
|
);
|
||||||
const result = await exportWebScripts(input);
|
const result = await exportWebScripts(input);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected exclusive output failure");
|
if (result.ok) throw new Error("Expected exclusive output failure");
|
||||||
expect(result.error.userMessage).toContain("already exists");
|
expect(result.error.userMessage).toContain("already exists");
|
||||||
expect(await readFile(marker, "utf8")).toBe("keep");
|
expect(await readFile(marker, "utf8")).toBe("keep");
|
||||||
@@ -229,7 +227,6 @@ describe("captured script publication failures and cleanup", () => {
|
|||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
controller.abort();
|
controller.abort();
|
||||||
const result = await exportWebScripts(input, { signal: controller.signal });
|
const result = await exportWebScripts(input, { signal: controller.signal });
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected cancellation");
|
if (result.ok) throw new Error("Expected cancellation");
|
||||||
expect(result.error._tag).toBe("AnalysisCancelledError");
|
expect(result.error._tag).toBe("AnalysisCancelledError");
|
||||||
await expect(
|
await expect(
|
||||||
@@ -249,7 +246,6 @@ describe("captured script publication failures and cleanup", () => {
|
|||||||
...input,
|
...input,
|
||||||
capture_path: `${input.capture_path}.missing`,
|
capture_path: `${input.capture_path}.missing`,
|
||||||
});
|
});
|
||||||
expect(missing.ok).toBe(false);
|
|
||||||
if (missing.ok) throw new Error("Expected unavailable input");
|
if (missing.ok) throw new Error("Expected unavailable input");
|
||||||
expect(missing.error.userMessage).toContain(
|
expect(missing.error.userMessage).toContain(
|
||||||
`${input.capture_path}.missing`,
|
`${input.capture_path}.missing`,
|
||||||
@@ -258,7 +254,6 @@ describe("captured script publication failures and cleanup", () => {
|
|||||||
...input,
|
...input,
|
||||||
capture_path: "capture.json",
|
capture_path: "capture.json",
|
||||||
});
|
});
|
||||||
expect(relative.ok).toBe(false);
|
|
||||||
if (relative.ok) throw new Error("Expected host path error");
|
if (relative.ok) throw new Error("Expected host path error");
|
||||||
expect(relative.error._tag).toBe("AnalysisInputError");
|
expect(relative.error._tag).toBe("AnalysisInputError");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ test("keeps unresolved target identity unknown while matching verified loaded sc
|
|||||||
try {
|
try {
|
||||||
await writeFile(entry, "export const fixture = true;\n");
|
await writeFile(entry, "export const fixture = true;\n");
|
||||||
const analysis = await analyzeJavaScriptApplication({ input_path: root });
|
const analysis = await analyzeJavaScriptApplication({ input_path: root });
|
||||||
expect(analysis.ok).toBe(true);
|
|
||||||
if (!analysis.ok) throw analysis.error;
|
if (!analysis.ok) throw analysis.error;
|
||||||
const provider = new V8InspectorProvider();
|
const provider = new V8InspectorProvider();
|
||||||
const input = {
|
const input = {
|
||||||
@@ -31,7 +30,6 @@ test("keeps unresolved target identity unknown while matching verified loaded sc
|
|||||||
observation_ms: 10,
|
observation_ms: 10,
|
||||||
};
|
};
|
||||||
const observed = await provider.observe(input);
|
const observed = await provider.observe(input);
|
||||||
expect(observed.ok).toBe(true);
|
|
||||||
if (!observed.ok) throw observed.error;
|
if (!observed.ok) throw observed.error;
|
||||||
const evidence = createJavaScriptRuntimeObservationEvidence(
|
const evidence = createJavaScriptRuntimeObservationEvidence(
|
||||||
"observe_javascript_runtime",
|
"observe_javascript_runtime",
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ describe.skipIf(process.platform !== "linux" || process.arch !== "x64")(
|
|||||||
path: fixture.path,
|
path: fixture.path,
|
||||||
output_directory: fixture.output,
|
output_directory: fixture.output,
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected boundary failure");
|
if (result.ok) throw new Error("expected boundary failure");
|
||||||
const error = projectAnalysisError(result.error);
|
const error = projectAnalysisError(result.error);
|
||||||
expect(["execution_failure", "unreadable_output"]).toContain(
|
expect(["execution_failure", "unreadable_output"]).toContain(
|
||||||
@@ -91,7 +90,6 @@ describe.skipIf(process.platform !== "linux" || process.arch !== "x64")(
|
|||||||
path: fixture.path,
|
path: fixture.path,
|
||||||
output_directory: fixture.output,
|
output_directory: fixture.output,
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected invalid UTF-8 boundary");
|
if (result.ok) throw new Error("expected invalid UTF-8 boundary");
|
||||||
expect(JSON.stringify(projectAnalysisError(result.error))).toContain(
|
expect(JSON.stringify(projectAnalysisError(result.error))).toContain(
|
||||||
"UTF-8 byte range",
|
"UTF-8 byte range",
|
||||||
@@ -131,7 +129,6 @@ describe.skipIf(process.platform !== "linux" || process.arch !== "x64")(
|
|||||||
path: fixture.path,
|
path: fixture.path,
|
||||||
output_directory: fixture.output,
|
output_directory: fixture.output,
|
||||||
});
|
});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected existing-output rejection");
|
if (result.ok) throw new Error("expected existing-output rejection");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
code: "invalid_request",
|
code: "invalid_request",
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ describe("enhanced MCP tools", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(calls).toBe(1);
|
expect(calls).toBe(1);
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected cancellation");
|
if (result.ok) throw new Error("expected cancellation");
|
||||||
expect(result.error._tag).toBe("AnalysisCancelledError");
|
expect(result.error._tag).toBe("AnalysisCancelledError");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -253,7 +253,6 @@ itWithCaptureCapability(
|
|||||||
cleanupHost,
|
cleanupHost,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected cleanup-incomplete failure");
|
if (result.ok) throw new Error("expected cleanup-incomplete failure");
|
||||||
if (!(result.error instanceof ProcessCaptureError)) throw result.error;
|
if (!(result.error instanceof ProcessCaptureError)) throw result.error;
|
||||||
const partial = result.error.partialObservation;
|
const partial = result.error.partialObservation;
|
||||||
@@ -455,7 +454,6 @@ itWithCaptureCapability(
|
|||||||
}),
|
}),
|
||||||
controller.signal,
|
controller.signal,
|
||||||
);
|
);
|
||||||
expect(cancelled.ok).toBe(false);
|
|
||||||
if (cancelled.ok) throw new Error("expected cancellation");
|
if (cancelled.ok) throw new Error("expected cancellation");
|
||||||
expect(cancelled.error.message).toContain("cancelled");
|
expect(cancelled.error.message).toContain("cancelled");
|
||||||
},
|
},
|
||||||
@@ -486,7 +484,6 @@ itWithCaptureCapability(
|
|||||||
signal,
|
signal,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected initial snapshot cancellation");
|
if (result.ok) throw new Error("expected initial snapshot cancellation");
|
||||||
expect(result.error).toMatchObject({
|
expect(result.error).toMatchObject({
|
||||||
reason: "cancelled",
|
reason: "cancelled",
|
||||||
@@ -522,7 +519,6 @@ itWithCaptureCapability(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const result = await resultPromise;
|
const result = await resultPromise;
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected final snapshot cancellation");
|
if (result.ok) throw new Error("expected final snapshot cancellation");
|
||||||
expect(initialSnapshotCompleted).toBe(true);
|
expect(initialSnapshotCompleted).toBe(true);
|
||||||
expect(result.error).toMatchObject({
|
expect(result.error).toMatchObject({
|
||||||
@@ -560,7 +556,6 @@ itWithCaptureCapability(
|
|||||||
captureSnapshot,
|
captureSnapshot,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("expected filesystem observation failure");
|
if (result.ok) throw new Error("expected filesystem observation failure");
|
||||||
expect(result.error).toMatchObject({
|
expect(result.error).toMatchObject({
|
||||||
reason: "capture_failed",
|
reason: "capture_failed",
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ it.each([0x01c0, 0x01c2, 0x01c4])(
|
|||||||
const path = join(directory, "fixture.exe");
|
const path = join(directory, "fixture.exe");
|
||||||
await writeFile(path, bytes);
|
await writeFile(path, bytes);
|
||||||
const parsed = await parseBinaryTarget(path);
|
const parsed = await parseBinaryTarget(path);
|
||||||
expect(parsed.ok).toBe(true);
|
|
||||||
if (!parsed.ok) throw parsed.error;
|
if (!parsed.ok) throw parsed.error;
|
||||||
expect(parsed.value).toMatchObject({
|
expect(parsed.value).toMatchObject({
|
||||||
kind: "executable",
|
kind: "executable",
|
||||||
@@ -31,7 +30,6 @@ it.each([0x01c0, 0x01c2, 0x01c4])(
|
|||||||
"inspect_managed_native_boundaries",
|
"inspect_managed_native_boundaries",
|
||||||
] as const) {
|
] as const) {
|
||||||
const observed = await client.execute(operation, {});
|
const observed = await client.execute(operation, {});
|
||||||
expect(observed.ok).toBe(true);
|
|
||||||
if (!observed.ok) throw observed.error;
|
if (!observed.ok) throw observed.error;
|
||||||
expect(observed.value.subject).toMatchObject({
|
expect(observed.value.subject).toMatchObject({
|
||||||
path,
|
path,
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ describe("native signature target identity", () => {
|
|||||||
const result = await new NativeMacOSProvider(runner, "darwin")
|
const result = await new NativeMacOSProvider(runner, "darwin")
|
||||||
.createClient(target)
|
.createClient(target)
|
||||||
.execute("inspect_signature", {});
|
.execute("inspect_signature", {});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected target-change failure");
|
if (result.ok) throw new Error("Expected target-change failure");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
code: "artifact_changed",
|
code: "artifact_changed",
|
||||||
@@ -113,7 +112,6 @@ describe("native signature target identity", () => {
|
|||||||
const result = await new NativeMacOSProvider(runner, "darwin")
|
const result = await new NativeMacOSProvider(runner, "darwin")
|
||||||
.createClient(target)
|
.createClient(target)
|
||||||
.execute("inspect_signature", {});
|
.execute("inspect_signature", {});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected target-change failure");
|
if (result.ok) throw new Error("Expected target-change failure");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
code: "artifact_changed",
|
code: "artifact_changed",
|
||||||
@@ -132,7 +130,6 @@ describe("native signature target identity", () => {
|
|||||||
const result = await new NativeMacOSProvider(runner, "darwin")
|
const result = await new NativeMacOSProvider(runner, "darwin")
|
||||||
.createClient(target)
|
.createClient(target)
|
||||||
.execute("inspect_signature", {});
|
.execute("inspect_signature", {});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected access denial");
|
if (result.ok) throw new Error("Expected access denial");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
code: "access_denied",
|
code: "access_denied",
|
||||||
@@ -156,7 +153,6 @@ describe("native signature target identity", () => {
|
|||||||
const result = await new NativeMacOSProvider(runner, "darwin")
|
const result = await new NativeMacOSProvider(runner, "darwin")
|
||||||
.createClient(target)
|
.createClient(target)
|
||||||
.execute("inspect_signature", {});
|
.execute("inspect_signature", {});
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) throw new Error("Expected access denial");
|
if (result.ok) throw new Error("Expected access denial");
|
||||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||||
code: "access_denied",
|
code: "access_denied",
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ it("accepts a byte-order mark before plist JSON", () => {
|
|||||||
const parsed = parsePlistJson(
|
const parsed = parsePlistJson(
|
||||||
'\uFEFF{"CFBundleIdentifier":"com.owned.fixture"}',
|
'\uFEFF{"CFBundleIdentifier":"com.owned.fixture"}',
|
||||||
);
|
);
|
||||||
expect(parsed.ok).toBe(true);
|
|
||||||
if (!parsed.ok) throw new Error("expected plist JSON to parse");
|
if (!parsed.ok) throw new Error("expected plist JSON to parse");
|
||||||
expect(parsed.value.bundle.identifier).toBe("com.owned.fixture");
|
expect(parsed.value.bundle.identifier).toBe("com.owned.fixture");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ async function createCompleteAppleProjection() {
|
|||||||
inventory_evidence: fragments,
|
inventory_evidence: fragments,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.ok).toBe(true);
|
|
||||||
if (!result.ok) throw new TypeError("Could not project fixture inventory");
|
if (!result.ok) throw new TypeError("Could not project fixture inventory");
|
||||||
const projection = appleApplicationProjectionResultSchema.parse(
|
const projection = appleApplicationProjectionResultSchema.parse(
|
||||||
result.value.normalized_result,
|
result.value.normalized_result,
|
||||||
|
|||||||
@@ -200,7 +200,6 @@ describe("managed application graph coverage", () => {
|
|||||||
managed_members: parserPartialEvidence,
|
managed_members: parserPartialEvidence,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(parserPartialProjection.ok).toBe(true);
|
|
||||||
if (!parserPartialProjection.ok)
|
if (!parserPartialProjection.ok)
|
||||||
throw new Error("partial projection failed");
|
throw new Error("partial projection failed");
|
||||||
const parserPartialResult = managedApplicationGraphResultSchema.parse(
|
const parserPartialResult = managedApplicationGraphResultSchema.parse(
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ describe("IDA provider composition", () => {
|
|||||||
diagnostics: { live_connection_probed: false },
|
diagnostics: { live_connection_probed: false },
|
||||||
});
|
});
|
||||||
const resolution = await provider.resolveAnalysisProfile(target);
|
const resolution = await provider.resolveAnalysisProfile(target);
|
||||||
expect(resolution.ok).toBe(true);
|
|
||||||
if (!resolution.ok) throw resolution.error;
|
if (!resolution.ok) throw resolution.error;
|
||||||
expect(resolution.value.profile.parameters).toMatchObject({
|
expect(resolution.value.profile.parameters).toMatchObject({
|
||||||
engine_version: null,
|
engine_version: null,
|
||||||
@@ -75,7 +74,6 @@ describe("IDA provider composition", () => {
|
|||||||
const first = await session.execute("procedure_pseudo_code", query);
|
const first = await session.execute("procedure_pseudo_code", query);
|
||||||
expect(first.ok && first.value.result).toContain("42");
|
expect(first.ok && first.value.result).toContain("42");
|
||||||
const snapshot = session.exportAnalysisSnapshot();
|
const snapshot = session.exportAnalysisSnapshot();
|
||||||
expect(snapshot.ok).toBe(true);
|
|
||||||
if (!snapshot.ok) throw snapshot.error;
|
if (!snapshot.ok) throw snapshot.error;
|
||||||
expect(snapshot.value.entries).toEqual([]);
|
expect(snapshot.value.entries).toEqual([]);
|
||||||
const profile = session.analysisProfile();
|
const profile = session.analysisProfile();
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ describe("MCP response budget configuration", () => {
|
|||||||
"9007199254740992",
|
"9007199254740992",
|
||||||
])("rejects malformed or unusable budgets: %j", (value) => {
|
])("rejects malformed or unusable budgets: %j", (value) => {
|
||||||
const parsed = parseMcpResponseBudget(value);
|
const parsed = parseMcpResponseBudget(value);
|
||||||
expect(parsed.ok).toBe(false);
|
|
||||||
if (parsed.ok) throw new Error("Expected invalid budget");
|
if (parsed.ok) throw new Error("Expected invalid budget");
|
||||||
expect(parsed.error.message).toContain("REA_MCP_MAX_RESPONSE_BYTES");
|
expect(parsed.error.message).toContain("REA_MCP_MAX_RESPONSE_BYTES");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user