























@@ -1,14 +1,15 @@
11import { readFileSync } from "node:fs";
22import { describe, expect, it } from "vitest";
3-import {
4-filterSparseMissingOxlintTargets,
5-shouldPrepareExtensionPackageBoundaryArtifacts,
6-} from "../../scripts/run-oxlint.mjs";
73import {
84createOxlintShards,
95createWindowsExtensionShards,
106resolveWindowsExtensionChunkSize,
7+shouldRunOxlintShardsSerial,
118} from "../../scripts/run-oxlint-shards.mjs";
9+import {
10+filterSparseMissingOxlintTargets,
11+shouldPrepareExtensionPackageBoundaryArtifacts,
12+} from "../../scripts/run-oxlint.mjs";
12131314describe("run-oxlint", () => {
1415it("prepares extension package boundary artifacts for normal lint runs", () => {
@@ -57,10 +58,65 @@ describe("run-oxlint", () => {
5758const shardedLintRunner = readFileSync("scripts/run-oxlint-shards.mjs", "utf8");
58595960expect(shardedLintRunner).toContain("OPENCLAW_OXLINT_SHARDS_SERIAL");
60-expect(shardedLintRunner).toContain('process.platform === "win32"');
61+expect(shardedLintRunner).toContain('platform === "win32"');
6162expect(shardedLintRunner).toContain("runShardsSerial");
6263});
636465+it("serializes broad oxlint shards on constrained local hosts", () => {
66+expect(
67+shouldRunOxlintShardsSerial({
68+env: {},
69+platform: "linux",
70+hostResources: { totalMemoryBytes: 8 * 1024 ** 3, logicalCpuCount: 4 },
71+}),
72+).toBe(true);
73+});
74+75+it("keeps oxlint shards parallel for CI and explicit full-speed runs", () => {
76+const constrainedHost = { totalMemoryBytes: 8 * 1024 ** 3, logicalCpuCount: 4 };
77+78+expect(
79+shouldRunOxlintShardsSerial({
80+env: { CI: "true" },
81+platform: "linux",
82+hostResources: constrainedHost,
83+}),
84+).toBe(false);
85+expect(
86+shouldRunOxlintShardsSerial({
87+env: { CI: "true", OPENCLAW_LOCAL_CHECK_MODE: "throttled" },
88+platform: "linux",
89+hostResources: constrainedHost,
90+}),
91+).toBe(true);
92+expect(
93+shouldRunOxlintShardsSerial({
94+env: { OPENCLAW_LOCAL_CHECK_MODE: "full" },
95+platform: "linux",
96+hostResources: constrainedHost,
97+}),
98+).toBe(false);
99+});
100+101+it("honors explicit oxlint shard serial overrides", () => {
102+const roomyHost = { totalMemoryBytes: 64 * 1024 ** 3, logicalCpuCount: 16 };
103+104+expect(
105+shouldRunOxlintShardsSerial({
106+env: { OPENCLAW_OXLINT_SHARDS_SERIAL: "1", CI: "true" },
107+platform: "linux",
108+hostResources: roomyHost,
109+}),
110+).toBe(true);
111+expect(
112+shouldRunOxlintShardsSerial({
113+env: { OPENCLAW_OXLINT_SHARDS_SERIAL: "0" },
114+platform: "linux",
115+hostResources: roomyHost,
116+}),
117+).toBe(false);
118+});
119+64120it("chunks extension oxlint shards on Windows", () => {
65121const shards = createOxlintShards({
66122cwd: "/repo",
@@ -130,10 +186,12 @@ describe("run-oxlint", () => {
130186131187it("keeps the default Windows oxlint extension chunk size for invalid overrides", () => {
132188expect(resolveWindowsExtensionChunkSize({})).toBe(8);
133-expect(resolveWindowsExtensionChunkSize({ OPENCLAW_OXLINT_WINDOWS_EXTENSION_CHUNK_SIZE: "0" }))
134-.toBe(8);
135-expect(resolveWindowsExtensionChunkSize({ OPENCLAW_OXLINT_WINDOWS_EXTENSION_CHUNK_SIZE: "abc" }))
136-.toBe(8);
189+expect(
190+resolveWindowsExtensionChunkSize({ OPENCLAW_OXLINT_WINDOWS_EXTENSION_CHUNK_SIZE: "0" }),
191+).toBe(8);
192+expect(
193+resolveWindowsExtensionChunkSize({ OPENCLAW_OXLINT_WINDOWS_EXTENSION_CHUNK_SIZE: "abc" }),
194+).toBe(8);
137195});
138196139197it("filters tracked targets missing from sparse checkouts", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。