返回 DeepSeek-Reasonix
macos-go-tests.mjs
根目录 / scripts / macos-go-tests.mjs
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 // Packages that carry darwin-tagged or _darwin sources — the only root-module
6 // code whose behaviour a Linux leg cannot prove. Pull requests run this set so
7 // the scarce macOS runners are not spent re-running the suite Linux already
8 // covers; pushes to main-v2 keep the full ./... sweep as the safety net. The
9 // list is enforced against the tree by macos-go-tests.test.mjs, so a new
10 // darwin source cannot quietly fall outside the pull-request lane.
11 export const darwinRoots = internalRoots(
12 "cli", "filelock", "fileutil", "mcplaunch", "notify", "pathidentity",
13 "projectiondb", "repair", "sandbox", "tool/builtin", "workspacelease",
14 );
15
16 export function selectPackages(packages, group) {
17 if (!["full", "darwin"].includes(group)) {
18 throw new Error(`Unknown macOS test group: ${group}`);
19 }
20 if (group === "full") return packages;
21 return packages.filter(pkg => darwinRoots.some(root => beneath(pkg, root)));
22 }
23
24 export function testArgs(packages, group) {
25 const selected = selectPackages(packages, group);
26 if (selected.length === 0) throw new Error(`Empty macOS test group: ${group}`);
27 return ["test", "-timeout=8m", ...selected];
28 }
29
30 function main(group) {
31 const { packages, status } = listPackages();
32 if (!packages) return status;
33 return runGoTest(`macOS ${group}`, selectPackages(packages, group), testArgs(packages, group));
34 }
35
36 if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
37 process.exitCode = main(process.argv[2]);
38 }
39
39 lines Plain Text