Files
reverse-engineering-anything/scripts/verify-bun-standalone.mjs
T
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

115 lines
3.3 KiB
JavaScript

#!/usr/bin/env node
import assert from "node:assert/strict";
import { readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { PrivateRuntimeRoot } from "../dist/process/PrivateRuntimeRoot.js";
import { parseEvidence } from "../dist/domain/evidence.js";
import { withVerifierCleanup } from "./lib/verifier-cleanup.mjs";
import { createVerifierCommands } from "./lib/verify-commands.mjs";
const root = await PrivateRuntimeRoot.create({ prefix: "rea-bun-verifier-" });
let commands;
const run = (command, args, options = {}) =>
commands.exec(command, args, {
timeout: 120_000,
maxBuffer: 16 * 1024 * 1024,
...options,
});
// The root holds the compiled target and child temporary files. Release it
// only after every owned command family has settled.
let commandsClosed = false;
await withVerifierCleanup(async () => {
commands = await createVerifierCommands();
const source = join(root.path, "hello.ts");
await writeFile(source, 'console.log("REA_BUN_VERIFICATION");\n');
const docker = process.argv.includes("--docker");
const binary = join(root.path, "hello");
const compiler = docker
? "oven/bun:1.4.0"
: (await run("bun", ["--version"])).stdout.trim();
if (docker) {
await run("docker", [
"run",
"--rm",
"--network=none",
"-v",
`${root.path}:/work`,
"-w",
"/work",
"oven/bun:1.4.0",
"build",
"--compile",
"hello.ts",
"--outfile",
"hello",
]);
} else {
await run("bun", ["build", "--compile", source, "--outfile", binary]);
}
const cli = async (command) =>
JSON.parse(
(
await run(
process.execPath,
["scripts/rea.mjs", command, binary, "--json"],
{
env: {
...process.env,
TMPDIR: root.path,
TMP: root.path,
TEMP: root.path,
},
},
)
).stdout,
);
const inspected = parseEvidence(
await cli("inspect-artifact"),
).normalized_result;
const graph = inspected.substeps.find(
(step) => step.operation === "inventory_artifact",
)?.evidence.normalized_result;
assert.equal(graph.manifest.root_format, "bun-standalone");
const module = graph.occurrences.find(
(row) =>
row.format_metadata?.kind === "bun-standalone-entry" &&
row.format_metadata.region === "contents" &&
row.format_metadata.entry_point,
);
assert.ok(module);
const extracted = parseEvidence(
await cli("extract-artifact"),
).normalized_result;
assert.equal(extracted.containment_verified, true);
assert.match(
await readFile(join(extracted.output_root, module.logical_path), "utf8"),
/REA_BUN_VERIFICATION/u,
);
console.log(
JSON.stringify(
{
compiler,
host: `${process.platform}-${process.arch}`,
docker,
root_format: graph.manifest.root_format,
entry_point: module.logical_path,
sha256: graph.nodes.find(
(node) => node.artifact_id === module.artifact_id,
)?.sha256,
extraction_verified: true,
target_executed: false,
},
null,
2,
),
);
}, [
async () => {
if (commands !== undefined) await commands.close();
commandsClosed = true;
},
async () => {
if (commandsClosed) await root.close();
},
]);