| 1 | import { resolve } from "node:path"; |
| 2 | import { fileURLToPath } from "node:url"; |
| 3 | import { beneath, internalRoots, listPackages, runGoTest } from "./go-test-groups.mjs"; |
| 4 | |
| 5 | // Start the long filesystem suites immediately on independent runners instead |
| 6 | // of leaving them behind hundreds of short packages in the residual queue. |
| 7 | export const isolatedGroups = ["acp", "agent", "boot", "bot", "control", "serve", "session", "worktree"]; |
| 8 | const smokeRoots = internalRoots( |
| 9 | "appidentity", "checkpoint", "cli", "desktoplauncher", "extension/sidecar", |
| 10 | "filelock", "fileops", "fileutil", "hook", "instruction", "mcplaunch", "notify", |
| 11 | // persistentshell drives a real ConPTY and a PowerShell wrapper that no other |
| 12 | // platform exercises, so Windows is the only lane that can prove it. |
| 13 | "persistentshell", "proc", |
| 14 | "lsp", "pathidentity", "projectiondb", "remote", "repair", "sandbox", "sessioncatalog", "sqliteuri", "sysproxy", |
| 15 | "topicstate", "winaclresidue", "workspacelease", |
| 16 | ).concat("reasonix/cmd"); |
| 17 | |
| 18 | export function selectPackages(packages, group) { |
| 19 | if (!["full", "smoke", ...isolatedGroups].includes(group)) { |
| 20 | throw new Error(`Unknown Windows test group: ${group}`); |
| 21 | } |
| 22 | const isolated = pkg => isolatedGroups.some(name => beneath(pkg, `reasonix/internal/${name}`)); |
| 23 | return packages.filter(pkg => { |
| 24 | if (isolatedGroups.includes(group)) return beneath(pkg, `reasonix/internal/${group}`); |
| 25 | return !isolated(pkg) && (group === "full" || smokeRoots.some(root => beneath(pkg, root))); |
| 26 | }); |
| 27 | } |
| 28 | |
| 29 | export function testArgs(packages, group) { |
| 30 | const selected = selectPackages(packages, group); |
| 31 | if (selected.length === 0) throw new Error(`Empty Windows test group: ${group}`); |
| 32 | const args = ["test", "-p", isolatedGroups.includes(group) ? "1" : "4", "-timeout=8m"]; |
| 33 | // Bot has produced process-level Windows exits without a Go stack or test |
| 34 | // name. JSON preserves the last start/output event and the subprocess exit |
| 35 | // status while keeping the whole package in one process (no retry or split). |
| 36 | if (group === "bot") args.push("-json"); |
| 37 | return [...args, ...selected]; |
| 38 | } |
| 39 | |
| 40 | function main(group) { |
| 41 | const { packages, status } = listPackages(); |
| 42 | if (!packages) return status; |
| 43 | return runGoTest(`Windows ${group}`, selectPackages(packages, group), testArgs(packages, group)); |
| 44 | } |
| 45 | |
| 46 | if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { |
| 47 | process.exitCode = main(process.argv[2]); |
| 48 | } |
| 49 |