Select checked implementations explicitly by target and ABI
This commit is contained in:
@@ -252,3 +252,35 @@ test("query dependencies propagate target requirements through selected getters"
|
||||
field.operations.find((o) => o.displayName === "get")!.execution = { kind: "snapshot", targets: ["browser"] };
|
||||
assert.throws(() => compileExecutionPlan(workspace), /MISSING_EXECUTION_TARGET.*test:selector-query.*server/);
|
||||
});
|
||||
|
||||
test("implementation selection is explicit, target checked and independent of manifest order", async () => {
|
||||
const { selectArtifactImplementation } = await import("../src/execution-world/index.js");
|
||||
const plan = compileExecutionPlan(await loadReaderWorkspace());
|
||||
const { manifest, read } = buildFixture(plan);
|
||||
const selection = {
|
||||
target: "browser",
|
||||
compatibility: "quixos-js-module-v1" as const,
|
||||
exports: [manifest.implementations[0]!.exports[0]!],
|
||||
};
|
||||
assert.equal(selectArtifactImplementation(manifest, selection).id, "browser");
|
||||
const alternative = structuredClone(manifest.implementations.find((i) => i.id === "browser")!);
|
||||
alternative.id = "browser-alternative";
|
||||
resign(alternative);
|
||||
manifest.implementations.unshift(alternative);
|
||||
await checkExecutionWorld(plan, [manifest], read);
|
||||
assert.throws(() => selectArtifactImplementation(manifest, selection), /AMBIGUOUS_IMPLEMENTATION/);
|
||||
assert.equal(selectArtifactImplementation(manifest, { ...selection, id: alternative.id }).id, alternative.id);
|
||||
manifest.implementations.reverse();
|
||||
assert.equal(selectArtifactImplementation(manifest, { ...selection, id: alternative.id }).id, alternative.id);
|
||||
for (const invalid of [
|
||||
{ ...selection, id: "missing" },
|
||||
{ ...selection, id: "service" },
|
||||
{ ...selection, id: alternative.id, target: "arduino" },
|
||||
{ ...selection, id: alternative.id, exports: ["not-exported"] },
|
||||
])
|
||||
assert.throws(() => selectArtifactImplementation(manifest, invalid), /IMPLEMENTATION_UNAVAILABLE/);
|
||||
assert.equal(
|
||||
selectArtifactImplementation(manifest, { ...selection, target: "server", compatibility: "quixos-service-v1" }).id,
|
||||
"service",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user