Files
morluto 7bcefead69 test: strengthen and prune audited test coverage (#8573)
* test: strengthen and prune audited test coverage

* test: require delivered DeepSeek skill instructions

* test: keep schema fixture types private

* test: verify Gemini receives skill instructions

* test: bind Qwen skill evidence to its tool result

* test: report NativeAOT verifier checks precisely

* fix: verify Ghidra cleanup paths reliably

* fix: verify Command Code skill activation

* test: tighten cleanup and fixture checks

* test: verify packet capture evidence is recorded

* fix: report HTTP3 capture provenance accurately

* test: preserve resource coverage through MCP

* test: prune repeated assertions and retain cancellation identity

* fix: validate client verifier fixture paths

* test: skip Copilot verifier cases on Windows

* test: keep verifier setup target relative
2026-11-02 02:13:32 +08:00

81 lines
3.2 KiB
TypeScript

import { symlink, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { createPythonPycService } from "../../../src/composition/pythonPyc.js";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
import { pythonPycFixture } from "../../../src/python/PythonPyc.fixture.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
describe("Python pyc stable filesystem boundary", () => {
it("reports non-file and malformed pyc selections as caller input errors", async () => {
const root = await createTestTempDirectory("rea-python-pyc-files-");
const path = join(root, "sample.pyc");
const alias = join(root, "alias.pyc");
const malformed = join(root, "malformed.pyc");
await writeFile(path, pythonPycFixture());
await writeFile(malformed, Buffer.from("not a pyc"));
await symlink(path, alias);
const service = createPythonPycService();
for (const [candidate, reason] of [
[root, "invalid_format"],
[alias, "invalid_format"],
[malformed, "invalid_format"],
[join(root, "missing.pyc"), "invalid_value"],
[join(path, "child.pyc"), "invalid_value"],
] as const) {
const result = await service.inspect({ path: candidate });
if (result.ok) throw new Error("Expected file acquisition failure");
expect(result.error).toMatchObject({
_tag: "AnalysisInputError",
operation: "inspect_python_pyc",
issues: [
{
path: ["path"],
reason,
message: expect.any(String),
},
],
});
}
});
it("returns typed resource and cancellation failures", async () => {
const root = await createTestTempDirectory("rea-python-pyc-budget-");
const path = join(root, "sample.pyc");
const bytes = pythonPycFixture("py311", { nested: true });
await writeFile(path, bytes);
const service = createPythonPycService();
const tooSmall = await service.inspect({ path, max_file_bytes: 16 });
if (tooSmall.ok) throw new Error("Expected resource budget failure");
expect(tooSmall.error._tag).toBe("AnalysisResourceConstraintError");
for (const [field, selected] of [
["max_objects", 1],
["max_depth", 1],
["max_string_bytes", 2],
] as const) {
const refused = await service.inspect({ path, [field]: selected });
if (refused.ok) throw new Error(`Expected ${field} refusal`);
if (field === "max_objects")
expect(refused.error._tag).toBe("AnalysisResourceConstraintError");
const projected = projectAnalysisError(refused.error);
expect(projected).toMatchObject({
code: "resource_constraint",
retryable: false,
remediation: {
action: expect.stringContaining(
`${field} (--${field.replaceAll("_", "-")})`,
),
},
});
const control = await service.inspect({ path });
expect(control.ok).toBe(true);
}
const cancelled = await service.inspect(
{ path },
{ signal: AbortSignal.abort() },
);
if (cancelled.ok) throw new Error("Expected cancellation");
expect(cancelled.error._tag).toBe("AnalysisCancelledError");
});
});