CI: bound extension-fast smoke scope and enforce SLA

This commit is contained in:
joshavant
2026-03-17 21:53:35 -05:00
parent e0e45b0005
commit 8effb32a90
3 changed files with 117 additions and 40 deletions

View File

@@ -8,13 +8,17 @@ import {
} from "../../scripts/test-extension.mjs";
const scriptPath = path.join(process.cwd(), "scripts", "test-extension.mjs");
type DryRunPlan = ReturnType<typeof resolveExtensionTestPlan> & {
maxTests?: number;
selectedTestFiles: string[];
};
function readPlan(args: string[], cwd = process.cwd()) {
const stdout = execFileSync(process.execPath, [scriptPath, ...args, "--dry-run", "--json"], {
cwd,
encoding: "utf8",
});
return JSON.parse(stdout) as ReturnType<typeof resolveExtensionTestPlan>;
return JSON.parse(stdout) as DryRunPlan;
}
function findZeroTestExtensionId(): string | undefined {
@@ -90,5 +94,14 @@ describe("scripts/test-extension.mjs", () => {
const plan = readPlan([extensionId!, "--allow-empty"]);
expect(plan.extensionId).toBe(extensionId);
expect(plan.testFiles).toHaveLength(0);
expect(plan.selectedTestFiles).toHaveLength(0);
});
it("limits selected tests when --max-tests is passed", () => {
const plan = readPlan(["discord", "--allow-empty", "--max-tests", "1"]);
expect(plan.extensionId).toBe("discord");
expect(plan.testFiles.length).toBeGreaterThan(1);
expect(plan.selectedTestFiles).toHaveLength(1);
expect(plan.maxTests).toBe(1);
});
});