39 lines
2.0 KiB
TypeScript
39 lines
2.0 KiB
TypeScript
/** Protocol/process qualification only; no application fixture enters runtime code. */
|
|||
|
|
import assert from "node:assert/strict";
|
||
|
|
import { mkdir, writeFile } from "node:fs/promises";
|
||
|
|
import { compileCapabilityResourceSource, compileCapabilitySource } from "../src/capability-language/index.js";
|
||
|
|
import { compileExecutionPlan } from "../src/execution-world/plan.js";
|
||
|
|
import { compileKernelProgram } from "../src/execution-world/kernel.js";
|
||
|
|
import { compileQueryProgram } from "../src/execution-world/queries.js";
|
||
|
|
const source = { repository: "https://example.test/device-owner.git", commit: "a".repeat(40) };
|
||
|
|
const pkg = compileCapabilityResourceSource(
|
||
|
|
`package Owner id "package:owner" revision "package:owner@1" {
|
||
|
|
function identity id "identity" : int32 -> record { pid: int32; child: int32; } execution remote;
|
||
|
|
}`,
|
||
|
|
{ source },
|
||
|
|
);
|
||
|
|
assert.ok(pkg.ok && pkg.resource.kind === "package", JSON.stringify(pkg.diagnostics));
|
||
|
|
for (const variant of ["base", "added"]) {
|
||
|
|
const commit = (variant === "base" ? "a" : "b").repeat(40);
|
||
|
|
const result = compileCapabilitySource(
|
||
|
|
`workspace Managed id "workspace:managed-process" revision "workspace:managed-process@${variant}" commit "${commit}" {
|
||
|
|
import package Owner;
|
||
|
|
${variant === "added" ? 'atom Independent id "atom:independent";' : ""}
|
||
|
|
}`,
|
||
|
|
"workspace.qx",
|
||
|
|
{ packages: new Map([["Owner", pkg.resource.revision]]), packageClosure: [pkg.resource.revision] },
|
||
|
|
);
|
||
|
|
assert.ok(result.ok, JSON.stringify(result.diagnostics));
|
||
|
|
const plan = compileExecutionPlan(result.workspace),
|
||
|
|
root = `dist/managed/${variant}`;
|
||
|
|
await mkdir(root, { recursive: true });
|
||
|
|
for (const [file, value] of Object.entries({
|
||
|
|
"candidate.json": result.workspace,
|
||
|
|
"execution-plan.json": plan,
|
||
|
|
"kernel.json": compileKernelProgram(plan),
|
||
|
|
"queries.json": compileQueryProgram(plan),
|
||
|
|
"source.json": { kind: "workspace", repository: "https://example.test/managed.git", commit },
|
||
|
|
}))
|
||
|
|
await writeFile(`${root}/${file}`, JSON.stringify(value));
|
||
|
|
}
|