Files
rea/tests/boundary/process/jebVerifier.test.ts
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

66 lines
2.8 KiB
TypeScript

import { execFile } from "node:child_process";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { promisify } from "node:util";
import { expect, it } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
const execute = promisify(execFile);
it("reports a decompile marker only when a nonempty requested marker was observed", async () => {
const root = await createTestTempDirectory("rea-jeb-verifier-");
const preload = join(root, "provider.mjs");
await writeFile(
preload,
`
import { registerHooks } from 'node:module';
const service = \`
export class JebAnalysisService {
async execute(name) {
if (name === 'inspect_jeb_client') return { ok: true, value: { normalized_result: { engine: { version: 'fixture', gui_client: false, endpoint: 'fixture' } } } };
if (name === 'open_jeb_project') return { ok: false, error: { message: 'not available' } };
if (name === 'list_jeb_units') return { ok: true, value: { normalized_result: { units: [{}] } } };
if (name === 'decompile_jeb_item') return { ok: true, value: { normalized_result: { text: process.env.REA_JEB_PROBE_TEXT ?? '' } } };
throw new Error('unexpected operation');
}
}\`;
const provider = \`export const createJebAnalysisProvider = () => ({ close: async () => {} });\`;
registerHooks({ resolve(specifier, context, next) {
if (context.parentURL?.endsWith('/scripts/verify-jeb.mjs')) {
if (specifier.endsWith('/JebAnalysisService.js')) return { shortCircuit: true, url: 'data:text/javascript,' + encodeURIComponent(service) };
if (specifier.endsWith('/composition/jeb.js')) return { shortCircuit: true, url: 'data:text/javascript,' + encodeURIComponent(provider) };
}
return next(specifier, context);
}});
`,
);
const invoke = (text: string, marker?: string) =>
execute(
process.execPath,
[
"--import",
preload,
"scripts/verify-jeb.mjs",
"--item-address",
"Lx;->x()V",
...(marker === undefined ? [] : ["--marker", marker]),
],
{ env: { ...process.env, REA_JEB_PROBE_TEXT: text }, timeout: 10_000 },
);
await expect(invoke("", undefined)).rejects.toMatchObject({
stderr: expect.stringContaining("Decompiled pseudo-code was empty"),
});
await expect(invoke("void x() {}", "missing")).rejects.toMatchObject({
stderr: expect.stringContaining("did not contain the fixture marker"),
});
await expect(invoke("void x() {}", "")).rejects.toMatchObject({
stderr: expect.stringContaining("--marker must not be empty"),
});
expect(
JSON.parse((await invoke("void x() {}", undefined)).stdout),
).toMatchObject({ ok: true, decompiled_marker_observed: false });
expect(JSON.parse((await invoke("void x() {}", "x()")).stdout)).toMatchObject(
{ ok: true, decompiled_marker_observed: true },
);
});