mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 21:23:45 +00:00
test(python): pin CPython code-object equality controls (#12040)
This commit is contained in:
1 parent
ca5676cee6
commit
ce0e3b3b9e
4 files changed
+174
No files matched your search
@@ -11,11 +11,38 @@ import {
|
||||
} from "../../src/python/PythonPyc.fixture.js";
|
||||
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../support/cli/cliFixture.js";
|
||||
import { pythonPycEqualityGolden } from "../fixtures/python-pyc-equality/golden.js";
|
||||
|
||||
const completePycEvidenceSchema = toolContract(
|
||||
"inspect_python_pyc",
|
||||
).outputSchema.safeExtend({ normalized_result: pythonPycSchema });
|
||||
|
||||
cliTest(
|
||||
"preserves CPython code-member identity in public Evidence",
|
||||
async ({ cli }) => {
|
||||
const golden = pythonPycEqualityGolden;
|
||||
const directory = await createTestTempDirectory("rea-pyc-code-equality-");
|
||||
const path = join(directory, "equality.pyc");
|
||||
await writeFile(path, Buffer.from(golden.pyc_base64, "base64"));
|
||||
const result = await cli.run({
|
||||
arguments: ["inspect-python-pyc", path, "--json"],
|
||||
});
|
||||
expect(result.exitCode, result.stderr).toBe(0);
|
||||
const report = completePycEvidenceSchema.parse(
|
||||
result.json,
|
||||
).normalized_result;
|
||||
expect(report.artifact).toMatchObject({ path, sha256: golden.sha256 });
|
||||
expect(report.code_objects[0]?.consts).toEqual(
|
||||
golden.cases.map((sample) => ({
|
||||
kind: "frozenset",
|
||||
length: sample.members,
|
||||
})),
|
||||
);
|
||||
expect(report.code_objects).toHaveLength(golden.code_objects);
|
||||
expect(report.coverage.status).toBe("complete");
|
||||
},
|
||||
);
|
||||
|
||||
const marshalUtf8 = (bytes: Buffer): Buffer => {
|
||||
const length = Buffer.alloc(4);
|
||||
length.writeUInt32LE(bytes.length);
|
||||
|
||||
Reference in new issue
Block a user