@afokapu/atdd-bun 0.10.80 → 0.10.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
mk,
|
|
30
30
|
writeReport,
|
|
31
31
|
} from "../_shared/interlocking.mjs";
|
|
32
|
+
import { assertedJourneyExecution } from "../../../lib/journey-chain.mjs";
|
|
32
33
|
|
|
33
34
|
const RULE = "tester.bun.interlocking-production-runner-used";
|
|
34
35
|
const roots = parseJsonEnv("ATDD_SCAN_ROOTS", []);
|
|
@@ -72,7 +73,9 @@ for (const scanRoot of roots) {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
// A journey test drives the runners through the production JourneyRunner: its asserted result counts
|
|
77
|
+
// when the journey-mediated chain is proven on the AST (lib/journey-chain.mjs), as for the Station Master.
|
|
78
|
+
const semantic = hasProductionExecutionProof(text, file, croot) || assertedJourneyExecution(raw, file, croot) ||
|
|
76
79
|
records.some((rec) => rec.actions.some((action) => stationMasterExecutionProof(text, action))) ||
|
|
77
80
|
(drivesStationMaster(text) && records.some((rec) => rec.actions.some((action) =>
|
|
78
81
|
stationModuleExecutionProof(text, station.text, action, station.file, croot),
|
package/integrity.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.10.
|
|
2
|
+
"version": "0.10.81",
|
|
3
3
|
"files": {
|
|
4
4
|
"HOOK_AUDIT.md": "5329d840db37671b1918f688ead26865473b87db73dbc75f7c8b2a8bbe8d6d43",
|
|
5
5
|
"PLANNER_PORT.md": "fb5935bac8b7ac18994de21e43ace3a5ef8cd55f85b0e3349fca261280054f11",
|
|
@@ -388,7 +388,7 @@
|
|
|
388
388
|
"detectors/bun_interlocking_coverage/_shared/interlocking.mjs": "8a90490daaaa6eecf4c971fb569da38156b45969d48755dbcf355175dde0b079",
|
|
389
389
|
"detectors/bun_interlocking_coverage/atdd.implementation.yaml": "f160517a8138ba3ca05e3d130e6fbfb796e643376f25743fdef4fc210196525b",
|
|
390
390
|
"detectors/bun_interlocking_coverage/checks/_map.json": "0a218ea319cc6258af7bd721c2154cb9561fe67e80d80ef32d08fc77bc9403c3",
|
|
391
|
-
"detectors/bun_interlocking_coverage/checks/interlocking_production_runner.mjs": "
|
|
391
|
+
"detectors/bun_interlocking_coverage/checks/interlocking_production_runner.mjs": "97224d46f0c4c3259f15e41f90bb7f9f5a4e651d4facd41f1e037cac919be500",
|
|
392
392
|
"detectors/bun_interlocking_coverage/checks/interlocking_route_coverage.mjs": "a2cff94a6bf9e11fe8e370332551742f9c7db317dcd57a88d08dc6c74f868f49",
|
|
393
393
|
"detectors/bun_interlocking_coverage/checks/interlocking_smoke_coverage.mjs": "28e016e1a4cd394291640679876b16c7d6a725530c7fbfa4bd1da8a354ecff86",
|
|
394
394
|
"detectors/bun_interlocking_coverage/checks/interlocking_trace_binds.mjs": "1cc3a11d50a075f3211a6d9cbf27aafcbf7e77b6a855ab040f765ec89dfe0eef",
|
|
@@ -1034,7 +1034,7 @@
|
|
|
1034
1034
|
"lib/frontend.mjs": "d6d9b29c3d7f2d162cda03bb34b20a3224a82887b6be3db7cab375510913c9a3",
|
|
1035
1035
|
"lib/imports.mjs": "3db4979269488fa26f6e7aefded6ece9c646be6587a10e249821a5a208109962",
|
|
1036
1036
|
"lib/interlocking.mjs": "d0803d080ac7d7477c51be70112df1e85213d339fd3c6b71f75f26145fa8accd",
|
|
1037
|
-
"lib/journey-chain.mjs": "
|
|
1037
|
+
"lib/journey-chain.mjs": "bdafc9cc3da4ade644aebacc6e1015e29285b764465588d764b7c581bade9025",
|
|
1038
1038
|
"lib/scan.mjs": "02b0fa864cab24157a8f27b50a87a2bb66a875f90cf6632c753c4627d61456ef",
|
|
1039
1039
|
"planner-nodes/ENFORCEMENT_SCOPE.yaml": "d8ec7039c219857f3d77af5d4d84612b533b69c1a5fcef935fbf46470adafed4",
|
|
1040
1040
|
"planner-nodes/nodes/planner.acceptance.abstract-fields-required.convention.yaml": "bd565693f0ae861f0561ad2f7a91a8c55f9a209c3acd59c5750cfcffd96a85d8",
|
package/lib/journey-chain.mjs
CHANGED
|
@@ -647,6 +647,81 @@ export function provenJourneyAction(stationText, stationFile, croot, name) {
|
|
|
647
647
|
everyModule(modules, "JourneyRunner", journeyExecutes(croot));
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
+
// The tester assertion vocabulary (shared tester layer `assertsExpression`), positive and under `.not`.
|
|
651
|
+
const MATCHERS = new Set(["toBe", "toBeDefined", "toEqual", "toStrictEqual", "toContain", "toContainEqual", "toMatchObject", "toMatch", "toBeTruthy"]);
|
|
652
|
+
const NEGATED_MATCHERS = new Set([...MATCHERS].filter((name) => name !== "toBeTruthy"));
|
|
653
|
+
|
|
654
|
+
// The journey declaration at `path` (relative to the consumer root, where its tests run) declares
|
|
655
|
+
// `action` among its entrypoint actions.
|
|
656
|
+
function declaresAction(croot, path, action) {
|
|
657
|
+
const file = resolve(croot, path);
|
|
658
|
+
if (!file.startsWith(resolve(croot) + sep) || !existsSync(file) || !statSync(file).isFile() || !globalThis.Bun?.YAML) return false;
|
|
659
|
+
try {
|
|
660
|
+
const actions = Bun.YAML.parse(readFileSync(file, "utf8"))?.entrypoint?.actions;
|
|
661
|
+
return Array.isArray(actions) && actions.includes(action);
|
|
662
|
+
} catch {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// A test module asserts a production JourneyRunner execution result, proven like provenJourneyAction:
|
|
668
|
+
// - a live `const` bound to `await <receiver>.execute("<action>", ...)`, the receiver being
|
|
669
|
+
// `new JourneyRunner("<journey declaration>")` or a const bound to one;
|
|
670
|
+
// - JourneyRunner binds to a local production import, and the declaration it is constructed from
|
|
671
|
+
// exists under the consumer root and declares that action;
|
|
672
|
+
// - the JourneyRunner module reaches InterlockingRunner -> TrainRunner (journeyExecutes);
|
|
673
|
+
// - a live `expect(<result or a member chain of it>).<matcher>(...)` whose argument binds to that
|
|
674
|
+
// const by checker symbol, not by spelling.
|
|
675
|
+
// The override contract covers the test module and every local module it reaches.
|
|
676
|
+
export function assertedJourneyExecution(testText, testFile, croot) {
|
|
677
|
+
if (!testText || !testFile || !croot) return false;
|
|
678
|
+
const ctx = analyze(testFile, testText);
|
|
679
|
+
if (tampered(ctx) || [...localImportClosure(testFile, croot)].some((module) => tampered(analyze(module)))) return false;
|
|
680
|
+
const results = new Set();
|
|
681
|
+
walk(ctx.source, (node) => {
|
|
682
|
+
if (!ts.isVariableDeclaration(node) || !ts.isIdentifier(node.name) || !node.initializer ||
|
|
683
|
+
!(ts.isVariableDeclarationList(node.parent) && node.parent.flags & ts.NodeFlags.Const)) return;
|
|
684
|
+
const awaited = ts.isAwaitExpression(node.initializer) ? unwrap(node.initializer) : null;
|
|
685
|
+
const action = awaited && ts.isCallExpression(awaited) && awaited.arguments[0];
|
|
686
|
+
if (!action || !ts.isStringLiteralLike(action) || dead(node, ctx.source) || insideCatch(node, ctx.source)) return;
|
|
687
|
+
const fromDeclaration = (construction) => {
|
|
688
|
+
const path = construction.arguments?.[0];
|
|
689
|
+
return Boolean(path && ts.isStringLiteralLike(path) && declaresAction(croot, path.text, action.text));
|
|
690
|
+
};
|
|
691
|
+
const modules = new Set();
|
|
692
|
+
if (executesImported(ctx, "JourneyRunner", croot, modules, fromDeclaration)(awaited) &&
|
|
693
|
+
everyModule(modules, "JourneyRunner", journeyExecutes(croot))) results.add(symbolOf(ctx, node.name));
|
|
694
|
+
});
|
|
695
|
+
if (!results.size) return false;
|
|
696
|
+
const boundToResult = (node) => {
|
|
697
|
+
node = unwrap(node);
|
|
698
|
+
while (node && ts.isPropertyAccessExpression(node)) node = unwrap(node.expression);
|
|
699
|
+
return Boolean(node) && ts.isIdentifier(node) && results.has(symbolOf(ctx, node));
|
|
700
|
+
};
|
|
701
|
+
const isExpect = (node) => {
|
|
702
|
+
if (!ts.isIdentifier(node) || node.text !== "expect") return false;
|
|
703
|
+
const declaration = declarationOf(ctx, node);
|
|
704
|
+
if (!declaration) return true;
|
|
705
|
+
const statement = ts.isImportSpecifier(declaration) ? declaration.parent.parent.parent : null;
|
|
706
|
+
return Boolean(statement && ts.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === "bun:test" &&
|
|
707
|
+
(declaration.propertyName ?? declaration.name).text === "expect");
|
|
708
|
+
};
|
|
709
|
+
let asserted = false;
|
|
710
|
+
walk(ctx.source, (node) => {
|
|
711
|
+
if (asserted) return false;
|
|
712
|
+
if (!ts.isCallExpression(node) || !isExpect(node.expression) || !boundToResult(node.arguments[0]) || dead(node, ctx.source)) return;
|
|
713
|
+
let access = node.parent, matchers = MATCHERS;
|
|
714
|
+
if (!ts.isPropertyAccessExpression(access) || access.expression !== node) return;
|
|
715
|
+
if (access.name.text === "not") {
|
|
716
|
+
access = access.parent;
|
|
717
|
+
matchers = NEGATED_MATCHERS;
|
|
718
|
+
}
|
|
719
|
+
asserted = ts.isPropertyAccessExpression(access) && matchers.has(access.name.text) &&
|
|
720
|
+
ts.isCallExpression(access.parent) && access.parent.expression === access;
|
|
721
|
+
});
|
|
722
|
+
return asserted;
|
|
723
|
+
}
|
|
724
|
+
|
|
650
725
|
// Names of every exported Station Master action proven by provenJourneyAction.
|
|
651
726
|
export function provenJourneyActions(stationText, stationFile, croot) {
|
|
652
727
|
if (!stationText || !stationFile || !croot) return [];
|