FN-6373: fix script test lane enumeration

Align script-test infrastructure with the current quality-test runner and AGENTS invariants.

- Expand run-quality-tests delegator scripts to concrete package quality lanes for dashboard shard planning.
- Cover grouped delegator expansion and non-delegating fallback behavior in ci-test-shard tests.
- Remove obsolete AGENTS button-freeze anchors from the invariant test.

Files changed:
 scripts/__tests__/agents-md-invariants.test.mjs |  2 --
 scripts/__tests__/ci-test-shard.test.mjs        | 32 +++++++++++++++++++++++++
 scripts/ci-test-shard.mjs                       | 28 ++++++++++++++++++++++
 3 files changed, 60 insertions(+), 2 deletions(-)

Fusion-Task-Id: FN-6373

Fusion-Task-Lineage: 5d833e17-c483-4a5b-818d-ae2f86a45084
This commit is contained in:
gsxdsm
2026-06-13 10:01:01 -07:00
parent 2974f7e878
commit 1fddc7ace7
3 changed files with 60 additions and 2 deletions

View File

@@ -10,8 +10,6 @@ const agentsPath = resolve(rootDir, "AGENTS.md");
const agents = readFileSync(agentsPath, "utf8");
const requiredAnchors = [
"STANDING DIRECTIVE: Buttons Are Frozen",
"Buttons Are Frozen (2026-05-13)",
"Port 4040",
"pnpm release --yes",
"@runfusion/fusion",

View File

@@ -554,6 +554,38 @@ test("U6: enumerateDashboardLanes reads lanes from a fixture package.json shape"
assert.deepEqual(lanes, ["test:quality:app:a", "test:quality:app:b", "test:quality:api"]);
});
test("U6: enumerateDashboardLanes expands run-quality-tests delegators to package leaf lanes", () => {
const scripts = {
test: "node scripts/run-quality-tests.mjs",
"test:quality:app": "node scripts/run-quality-tests.mjs --group app",
"test:quality:app:a": "node scripts/run-vitest-with-heap.mjs run --project app-a",
"test:quality:app:b": "node scripts/run-vitest-with-heap.mjs run --project app-b --shard=1/2",
"test:quality:app:aggregate": "pnpm run test:quality:app:a && pnpm run test:quality:app:b",
"test:quality:api": "node scripts/run-quality-tests.mjs --group=api",
"test:quality:api:a": "node scripts/run-vitest-with-heap.mjs run --project api-a",
"test:quality:api:delegator": "node scripts/run-quality-tests.mjs --group api",
"test:quality:misc": "node scripts/run-vitest-with-heap.mjs run --project misc",
"test:deep": "vitest run --project deep",
};
assert.deepEqual(enumerateDashboardLanes(scripts, "test"), [
"test:quality:app:a",
"test:quality:app:b",
"test:quality:api:a",
"test:quality:misc",
]);
assert.deepEqual(enumerateDashboardLanes(scripts, "test:quality:app"), [
"test:quality:app:a",
"test:quality:app:b",
]);
assert.deepEqual(enumerateDashboardLanes(scripts, "test:quality:api"), ["test:quality:api:a"]);
});
test("U6: enumerateDashboardLanes preserves single-leaf fallback for non-delegating scripts", () => {
assert.deepEqual(enumerateDashboardLanes({ test: "node custom-runner.mjs" }, "test"), ["test"]);
assert.deepEqual(enumerateDashboardLanes({}, "test"), []);
});
test("U6: laneProjectNames extracts --project targets including = and space forms", () => {
assert.deepEqual(laneProjectNames("vitest run --project foo --project=bar baz"), ["foo", "bar"]);
});

View File

@@ -565,12 +565,40 @@ export function enumerateDashboardLanes(scripts, entryScript = "test") {
while ((match = re.exec(command)) !== null) names.push(match[1]);
return names;
};
const delegatedGroup = (command) => {
const match = command.match(/--group(?:=|\s+)(app|api)\b/);
return match?.[1] ?? null;
};
const isQualityLeaf = ([name, command]) => (
name.startsWith("test:quality:")
&& command.includes("--project")
&& !command.includes("run-quality-tests")
&& referencedRuns(command).length === 0
);
const pushLane = (lane) => {
if (seen.has(lane)) return;
seen.add(lane);
lanes.push(lane);
};
const expandQualityDelegation = (command) => {
// The dashboard package's quality-test runner owns the current lane manifest;
// expand delegators back to real package.json leaf scripts so CI can shard them.
const group = delegatedGroup(command);
const prefix = group ? `test:quality:${group}:` : "test:quality:";
for (const [name, leafCommand] of Object.entries(scripts ?? {})) {
if (name.startsWith(prefix) && isQualityLeaf([name, leafCommand])) pushLane(name);
}
};
const visit = (scriptName) => {
if (seen.has(scriptName)) return;
seen.add(scriptName);
const command = scripts?.[scriptName];
if (typeof command !== "string") return;
if (command.includes("run-quality-tests")) {
expandQualityDelegation(command);
return;
}
const children = referencedRuns(command);
if (children.length === 0) {
// Leaf: a lane that actually invokes a test runner.