windows-e2e-shards.test.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. import { readFileSync } from "node:fs";
  2. import { EventEmitter } from "node:events";
  3. import { join, resolve } from "node:path";
  4. import { describe, expect, it, vi } from "vitest";
  5. import {
  6. createWindowsE2ERunId,
  7. createWindowsE2EShardPlan,
  8. executeWindowsE2EShardPlan,
  9. listDefaultFormalE2ESpecs,
  10. partitionE2ESpecsByWeight,
  11. resolveWindowsE2EShardTotal,
  12. } from "../scripts/run-windows-e2e-shards.mjs";
  13. const repoRoot = resolve("C:/repo");
  14. const desktopDir = join(repoRoot, "packages/desktop");
  15. function createPlan(overrides: Record<string, unknown> = {}) {
  16. return createWindowsE2EShardPlan({
  17. args: [],
  18. desktopDir,
  19. env: { ZCODE_E2E_RUN_ID: "local-full", ZCODE_E2E_SHARD_TOTAL: "2" },
  20. platform: "win32",
  21. repoRoot,
  22. ...overrides,
  23. });
  24. }
  25. describe("Windows E2E shard runner", () => {
  26. it("uses entropy to distinguish automatic run IDs from the same timestamp and PID", () => {
  27. const timestamp = new Date("2026-07-11T00:30:00.123Z");
  28. const firstRunId = createWindowsE2ERunId({
  29. entropy: "entropy-a",
  30. processId: 4242,
  31. timestamp,
  32. });
  33. const secondRunId = createWindowsE2ERunId({
  34. entropy: "entropy-b",
  35. processId: 4242,
  36. timestamp,
  37. });
  38. expect(firstRunId).not.toBe(secondRunId);
  39. expect(firstRunId).toContain("20260711003000123-p4242-entropy-a");
  40. expect(secondRunId).toContain("20260711003000123-p4242-entropy-b");
  41. });
  42. it("derives disjoint paths from automatic run IDs while preserving an explicit run ID", () => {
  43. const timestamp = new Date("2026-07-11T00:30:00.123Z");
  44. vi.useFakeTimers();
  45. vi.setSystemTime(timestamp);
  46. try {
  47. const firstPlan = createPlan({
  48. // 修复原因:默认 full run 已改为单 shard;路径隔离断言必须显式进入并发分片场景。
  49. env: { ZCODE_E2E_SHARD_TOTAL: "2" },
  50. processId: 4242,
  51. runIdEntropy: "entropy-a",
  52. runIdTimestamp: timestamp,
  53. });
  54. const secondPlan = createPlan({
  55. env: { ZCODE_E2E_SHARD_TOTAL: "2" },
  56. processId: 4242,
  57. runIdEntropy: "entropy-b",
  58. runIdTimestamp: timestamp,
  59. });
  60. expect(firstPlan.runId).not.toBe(secondPlan.runId);
  61. for (const key of [
  62. "ZCODE_E2E_HOME_DIR",
  63. "ZCODE_E2E_ARTIFACT_DIR",
  64. "ZCODE_E2E_NETWORK_CAPTURE_DIR",
  65. ] as const) {
  66. const firstPaths = new Set(firstPlan.children.map((child) => child.env[key]));
  67. const secondPaths = new Set(secondPlan.children.map((child) => child.env[key]));
  68. expect([...firstPaths].filter((path) => secondPaths.has(path))).toEqual([]);
  69. }
  70. const explicitPlan = createPlan({
  71. env: { ZCODE_E2E_RUN_ID: "explicit-compatible-run" },
  72. processId: 4242,
  73. runIdEntropy: "ignored-entropy",
  74. runIdTimestamp: timestamp,
  75. });
  76. expect(explicitPlan.runId).toBe("explicit-compatible-run");
  77. } finally {
  78. vi.useRealTimers();
  79. }
  80. });
  81. it("keeps a default full Windows run single-sharded regardless of machine resources", () => {
  82. expect(
  83. resolveWindowsE2EShardTotal({
  84. args: [],
  85. env: {},
  86. platform: "win32",
  87. logicalCpuCount: 8,
  88. totalMemoryBytes: 32 * 1024 ** 3,
  89. }),
  90. ).toBe(1);
  91. expect(
  92. resolveWindowsE2EShardTotal({
  93. args: [],
  94. env: {},
  95. platform: "win32",
  96. logicalCpuCount: 6,
  97. totalMemoryBytes: 16 * 1024 ** 3,
  98. }),
  99. ).toBe(1);
  100. expect(
  101. resolveWindowsE2EShardTotal({
  102. args: [],
  103. env: {},
  104. platform: "win32",
  105. logicalCpuCount: 4,
  106. totalMemoryBytes: 8 * 1024 ** 3,
  107. }),
  108. ).toBe(1);
  109. const plan = createPlan({
  110. env: { ZCODE_E2E_RUN_ID: "default-single" },
  111. });
  112. expect(plan.shardTotal).toBe(1);
  113. expect(plan.children).toHaveLength(1);
  114. expect(plan.children[0]?.args.some((arg) => arg.startsWith("--shard"))).toBe(false);
  115. expect(plan.children[0]?.env.ZCODE_E2E_HOME_DIR).toBe(
  116. join(desktopDir, ".e2e-home-default-single"),
  117. );
  118. });
  119. it("lists the default formal specs without manual-review or live provider cases", () => {
  120. const specs = listDefaultFormalE2ESpecs(resolve(process.cwd(), "packages/desktop"));
  121. // Bug 根因:formal case 由目录动态发现,固定总数会让新增或删除合法 case 误伤 pre-push。
  122. // 用稳定的 smoke 包含关系确认发现结果非空,其余断言只校验默认集合的语义边界。
  123. expect(specs).toContain("./test/e2e/smoke.test.ts");
  124. expect(specs).not.toContain("./test/e2e/upstream-provider.test.ts");
  125. expect(specs.some((spec) => spec.includes("/manual-review/"))).toBe(false);
  126. expect(specs.some((spec) => spec.includes("conversation-session-ssh-remote"))).toBe(false);
  127. const sshSpecs = listDefaultFormalE2ESpecs(resolve(process.cwd(), "packages/desktop"), {
  128. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  129. ZCODE_E2E_SSH_USERNAME: "root",
  130. ZCODE_E2E_SSH_PASSWORD: "secret-from-test-env",
  131. });
  132. expect(sshSpecs).toContain(
  133. "./test/e2e/conversation-session/conversation-session-ssh-remote-connection-p0.test.ts",
  134. );
  135. });
  136. it("uses deterministic LPT weights and a fallback for new specs", () => {
  137. const buckets = partitionE2ESpecsByWeight(
  138. ["./a.test.ts", "./b.test.ts", "./c.test.ts", "./new.test.ts"],
  139. 2,
  140. {
  141. defaultWeightMs: 40,
  142. weights: {
  143. "./a.test.ts": 100,
  144. "./b.test.ts": 80,
  145. "./c.test.ts": 20,
  146. },
  147. },
  148. );
  149. expect(buckets).toEqual([
  150. { estimatedWeightMs: 120, specs: ["./a.test.ts", "./c.test.ts"] },
  151. { estimatedWeightMs: 120, specs: ["./b.test.ts", "./new.test.ts"] },
  152. ]);
  153. });
  154. it("passes weighted spec groups explicitly instead of native contiguous shards", () => {
  155. const weightedSpecBuckets = [
  156. { estimatedWeightMs: 100, specs: ["./test/e2e/smoke.test.ts"] },
  157. { estimatedWeightMs: 90, specs: ["./test/e2e/container-boot.test.ts"] },
  158. ];
  159. const plan = createPlan({ weightedSpecBuckets });
  160. expect(plan.distributionKind).toBe("historical-lpt");
  161. expect(plan.children.map((child) => child.env.ZCODE_E2E_SPEC)).toEqual([
  162. "./test/e2e/smoke.test.ts",
  163. "./test/e2e/container-boot.test.ts",
  164. ]);
  165. expect(
  166. plan.children.every((child) => child.args.every((arg) => !arg.startsWith("--shard"))),
  167. ).toBe(true);
  168. });
  169. it("plans two isolated shards for an explicit two-shard run", () => {
  170. const plan = createPlan();
  171. expect(plan.shardTotal).toBe(2);
  172. expect(plan.children).toHaveLength(2);
  173. expect(plan.children.map((child) => child.shardId)).toEqual(["1/2", "2/2"]);
  174. expect(plan.children.map((child) => child.args.at(-1))).toEqual(["--shard=1/2", "--shard=2/2"]);
  175. for (const key of [
  176. "ZCODE_E2E_HOME_DIR",
  177. "ZCODE_E2E_RUN_ID",
  178. "ZCODE_E2E_ARTIFACT_DIR",
  179. "ZCODE_E2E_NETWORK_CAPTURE_DIR",
  180. ] as const) {
  181. expect(new Set(plan.children.map((child) => child.env[key])).size).toBe(2);
  182. }
  183. for (const child of plan.children) {
  184. expect(child.env.ZCODE_E2E_SKIP_BUILD).toBe("1");
  185. expect(child.env.ZCODE_E2E_SKIP_AGENT_BUILD).toBe("1");
  186. expect(child.summaryPath).toBe(join(child.artifactDir, "summary.json"));
  187. }
  188. });
  189. it("keeps every default HOME disjoint across concurrent runner run IDs", () => {
  190. const firstPlan = createPlan({
  191. // 修复原因:覆盖 env 会同时移除 createPlan 默认的 shard 数,需保留显式分片前提。
  192. env: {
  193. ZCODE_E2E_RUN_ID: "concurrent-run-a",
  194. ZCODE_E2E_SHARD_TOTAL: "2",
  195. },
  196. });
  197. const secondPlan = createPlan({
  198. env: {
  199. ZCODE_E2E_RUN_ID: "concurrent-run-b",
  200. ZCODE_E2E_SHARD_TOTAL: "2",
  201. },
  202. });
  203. const firstHomes = new Set(firstPlan.children.map((child) => child.env.ZCODE_E2E_HOME_DIR));
  204. const secondHomes = new Set(secondPlan.children.map((child) => child.env.ZCODE_E2E_HOME_DIR));
  205. expect([...firstHomes].filter((home) => secondHomes.has(home))).toEqual([]);
  206. expect([...firstHomes].every((home) => home.includes("concurrent-run-a"))).toBe(true);
  207. expect([...secondHomes].every((home) => home.includes("concurrent-run-b"))).toBe(true);
  208. });
  209. it("preserves an explicit HOME for a single-child run", () => {
  210. const explicitHomeRoot = resolve("C:/e2e-homes/single");
  211. const plan = createPlan({
  212. env: {
  213. ZCODE_E2E_HOME_DIR: explicitHomeRoot,
  214. ZCODE_E2E_RUN_ID: "explicit-single-home-run",
  215. },
  216. });
  217. expect(plan.shardTotal).toBe(1);
  218. expect(plan.children[0]?.env.ZCODE_E2E_HOME_DIR).toBe(explicitHomeRoot);
  219. });
  220. it("adds run and shard identity below an explicit sharded HOME base", () => {
  221. const explicitHomeRoot = resolve("C:/e2e-homes");
  222. const plan = createPlan({
  223. env: {
  224. ZCODE_E2E_HOME_DIR: explicitHomeRoot,
  225. ZCODE_E2E_RUN_ID: "explicit-home-run",
  226. ZCODE_E2E_SHARD_TOTAL: "2",
  227. },
  228. });
  229. expect(plan.children.map((child) => child.env.ZCODE_E2E_HOME_DIR)).toEqual([
  230. join(explicitHomeRoot, "explicit-home-run", "shard-1-of-2"),
  231. join(explicitHomeRoot, "explicit-home-run", "shard-2-of-2"),
  232. ]);
  233. });
  234. it("builds desktop and agent once before starting both children concurrently", async () => {
  235. const plan = createPlan();
  236. expect(plan.buildSteps[1]?.env.ZCODE_DESKTOP_AGENT_BUILD_MODE).toBe("turbo");
  237. const events: string[] = [];
  238. const childResolvers: Array<(result: { exitCode: number }) => void> = [];
  239. const execution = executeWindowsE2EShardPlan(plan, {
  240. now: (() => {
  241. let value = 1_000;
  242. return () => (value += 50);
  243. })(),
  244. summaryExists: () => true,
  245. spawnStep: vi.fn(async (step) => {
  246. events.push(`start:${step.id}`);
  247. if (step.kind === "build") {
  248. events.push(`finish:${step.id}`);
  249. return { exitCode: 0 };
  250. }
  251. return await new Promise<{ exitCode: number }>((resolveChild) => {
  252. childResolvers.push(resolveChild);
  253. });
  254. }),
  255. writeManifest: vi.fn(),
  256. printManifest: vi.fn(),
  257. });
  258. await vi.waitFor(() => expect(childResolvers).toHaveLength(2));
  259. expect(events).toEqual([
  260. "start:build-desktop",
  261. "finish:build-desktop",
  262. "start:build-agent",
  263. "finish:build-agent",
  264. "start:shard-1-of-2",
  265. "start:shard-2-of-2",
  266. ]);
  267. childResolvers[1]?.({ exitCode: 0 });
  268. childResolvers[0]?.({ exitCode: 0 });
  269. const manifest = await execution;
  270. expect(manifest.wallDurationMs).toBe(50);
  271. expect(manifest.children.map((child) => child.exitCode)).toEqual([0, 0]);
  272. });
  273. it.each([
  274. {
  275. label: "targeted CLI",
  276. args: ["--spec=./test/e2e/container-boot.test.ts", "--shards=10"],
  277. env: { ZCODE_E2E_SHARD_TOTAL: "4" },
  278. },
  279. {
  280. label: "targeted env",
  281. args: ["--shards=10"],
  282. env: {
  283. ZCODE_E2E_SPEC: "./test/e2e/container-boot.test.ts",
  284. ZCODE_E2E_SHARD_TOTAL: "4",
  285. },
  286. },
  287. {
  288. label: "capture",
  289. args: ["--shards=10"],
  290. env: { E2E_PROVIDER_HTTP_MODE: "capture", ZCODE_E2E_SHARD_TOTAL: "4" },
  291. },
  292. {
  293. label: "manual review",
  294. args: ["--shards=10"],
  295. env: { ZCODE_E2E_MANUAL_REVIEW: "1", ZCODE_E2E_SHARD_TOTAL: "4" },
  296. },
  297. ])("keeps $label runs single despite explicit shard overrides", ({ args, env }) => {
  298. const plan = createPlan({ args, env });
  299. expect(plan.shardTotal).toBe(1);
  300. expect(plan.children).toHaveLength(1);
  301. });
  302. it("keeps non-Windows runs single by default", () => {
  303. expect(resolveWindowsE2EShardTotal({ args: [], env: {}, platform: "darwin" })).toBe(1);
  304. });
  305. it("validates explicit overrides and strips the runner-only option", () => {
  306. const plan = createPlan({
  307. args: ["--logLevel=warn", "--shards=3", "--mochaOpts.timeout=9000"],
  308. env: { ZCODE_E2E_SHARD_TOTAL: "4", ZCODE_E2E_RUN_ID: "override" },
  309. });
  310. expect(plan.shardTotal).toBe(3);
  311. expect(plan.wdioArgs).toEqual(["--logLevel=warn", "--mochaOpts.timeout=9000"]);
  312. expect(plan.children.map((child) => child.args.at(-1))).toEqual([
  313. "--shard=1/3",
  314. "--shard=2/3",
  315. "--shard=3/3",
  316. ]);
  317. expect(() =>
  318. resolveWindowsE2EShardTotal({ args: ["--shards=0"], env: {}, platform: "win32" }),
  319. ).toThrow("positive integer");
  320. expect(() =>
  321. resolveWindowsE2EShardTotal({
  322. args: [],
  323. env: { ZCODE_E2E_SHARD_TOTAL: "two" },
  324. platform: "win32",
  325. }),
  326. ).toThrow("positive integer");
  327. });
  328. it("does not reshard a native WDIO shard from any override", () => {
  329. expect(
  330. resolveWindowsE2EShardTotal({
  331. args: ["--shard=1/2"],
  332. env: { ZCODE_E2E_SHARD_TOTAL: "4" },
  333. platform: "win32",
  334. }),
  335. ).toBe(1);
  336. expect(
  337. resolveWindowsE2EShardTotal({
  338. args: ["--shard=1/2", "--shards=3"],
  339. env: { ZCODE_E2E_SHARD_TOTAL: "4" },
  340. platform: "win32",
  341. }),
  342. ).toBe(1);
  343. });
  344. it("waits for every child, writes one manifest, and fails when any shard fails", async () => {
  345. const plan = createPlan();
  346. const completed: string[] = [];
  347. const writeManifest = vi.fn();
  348. const printManifest = vi.fn();
  349. let caught: unknown;
  350. try {
  351. await executeWindowsE2EShardPlan(plan, {
  352. now: () => 2_000,
  353. summaryExists: () => true,
  354. spawnStep: async (step) => {
  355. if (step.kind === "build") return { exitCode: 0 };
  356. completed.push(step.id);
  357. return { exitCode: step.shardIndex === 1 ? 7 : 0 };
  358. },
  359. writeManifest,
  360. printManifest,
  361. });
  362. } catch (error) {
  363. caught = error;
  364. }
  365. expect(completed).toEqual(["shard-1-of-2", "shard-2-of-2"]);
  366. expect(writeManifest).toHaveBeenCalledOnce();
  367. expect(printManifest).toHaveBeenCalledOnce();
  368. expect(caught).toMatchObject({
  369. message: expect.stringContaining("shard 1/2 exited with code 7"),
  370. manifest: {
  371. runId: "local-full",
  372. shardTotal: 2,
  373. wallDurationMs: 0,
  374. children: [
  375. {
  376. shardId: "1/2",
  377. exitCode: 7,
  378. artifactDir: plan.children[0]?.artifactDir,
  379. summaryPath: plan.children[0]?.summaryPath,
  380. },
  381. {
  382. shardId: "2/2",
  383. exitCode: 0,
  384. artifactDir: plan.children[1]?.artifactDir,
  385. summaryPath: plan.children[1]?.summaryPath,
  386. },
  387. ],
  388. },
  389. });
  390. });
  391. it("rejects a zero-exit shard that produced no summary", async () => {
  392. const plan = createPlan();
  393. await expect(
  394. executeWindowsE2EShardPlan(plan, {
  395. now: () => 2_000,
  396. spawnStep: async () => ({ exitCode: 0 }),
  397. summaryExists: () => false,
  398. writeManifest: vi.fn(),
  399. printManifest: vi.fn(),
  400. }),
  401. ).rejects.toMatchObject({
  402. message: expect.stringContaining("missing shard summary"),
  403. manifest: {
  404. children: expect.arrayContaining([
  405. expect.objectContaining({ exitCode: 1, error: expect.stringContaining("summary.json") }),
  406. ]),
  407. },
  408. });
  409. });
  410. it("records a rejected shard start, waits for the delayed shard, and writes one manifest", async () => {
  411. const plan = createPlan();
  412. const writeManifest = vi.fn();
  413. const printManifest = vi.fn();
  414. let finishDelayedShard: (() => void) | undefined;
  415. const execution = executeWindowsE2EShardPlan(plan, {
  416. now: () => 2_000,
  417. summaryExists: () => true,
  418. spawnStep: (step) => {
  419. if (step.kind === "build") return Promise.resolve({ exitCode: 0 });
  420. if (step.shardIndex === 1) return Promise.reject(new Error("spawn pnpm EAGAIN"));
  421. return new Promise<{ exitCode: number }>((resolveChild) => {
  422. finishDelayedShard = () => resolveChild({ exitCode: 0 });
  423. });
  424. },
  425. writeManifest,
  426. printManifest,
  427. });
  428. await vi.waitFor(() => expect(finishDelayedShard).toBeTypeOf("function"));
  429. await Promise.resolve();
  430. expect(writeManifest).not.toHaveBeenCalled();
  431. finishDelayedShard?.();
  432. await expect(execution).rejects.toMatchObject({
  433. message: expect.stringContaining("shard 1/2 failed to start: spawn pnpm EAGAIN"),
  434. manifest: {
  435. children: [
  436. expect.objectContaining({
  437. shardId: "1/2",
  438. exitCode: 1,
  439. error: "spawn pnpm EAGAIN",
  440. }),
  441. expect.objectContaining({ shardId: "2/2", exitCode: 0 }),
  442. ],
  443. },
  444. });
  445. expect(writeManifest).toHaveBeenCalledOnce();
  446. expect(printManifest).toHaveBeenCalledOnce();
  447. });
  448. it("terminates another cancellable shard after an unrecoverable start error", async () => {
  449. const plan = createPlan();
  450. let finishSecondShard: ((result: { exitCode: number; signal?: string }) => void) | undefined;
  451. const terminateSecondShard = vi.fn(() => {
  452. finishSecondShard?.({ exitCode: 1, signal: "SIGTERM" });
  453. });
  454. const execution = executeWindowsE2EShardPlan(plan, {
  455. now: () => 2_000,
  456. summaryExists: () => true,
  457. spawnStep: (step) => {
  458. if (step.kind === "build") return Promise.resolve({ exitCode: 0 });
  459. if (step.shardIndex === 1) return Promise.reject(new Error("spawn pnpm ENOMEM"));
  460. return {
  461. result: new Promise<{ exitCode: number; signal?: string }>((resolveChild) => {
  462. finishSecondShard = resolveChild;
  463. }),
  464. terminate: terminateSecondShard,
  465. };
  466. },
  467. writeManifest: vi.fn(),
  468. printManifest: vi.fn(),
  469. });
  470. await expect(execution).rejects.toMatchObject({
  471. manifest: {
  472. children: [
  473. expect.objectContaining({ error: "spawn pnpm ENOMEM" }),
  474. expect.objectContaining({ signal: "SIGTERM" }),
  475. ],
  476. },
  477. });
  478. expect(terminateSecondShard).toHaveBeenCalledOnce();
  479. });
  480. it("terminates active shards on a parent signal and reports the interrupted run", async () => {
  481. const plan = createPlan();
  482. const signalSource = new EventEmitter();
  483. const childResolvers = new Map<
  484. number,
  485. (result: { exitCode: number; signal?: string }) => void
  486. >();
  487. const terminates: Array<ReturnType<typeof vi.fn>> = [];
  488. const execution = executeWindowsE2EShardPlan(plan, {
  489. now: () => 2_000,
  490. summaryExists: () => true,
  491. signalSource,
  492. spawnStep: (step) => {
  493. if (step.kind === "build") return Promise.resolve({ exitCode: 0 });
  494. const terminate = vi.fn(() => {
  495. childResolvers.get(step.shardIndex)?.({ exitCode: 1, signal: "SIGTERM" });
  496. });
  497. terminates.push(terminate);
  498. return {
  499. result: new Promise<{ exitCode: number; signal?: string }>((resolveChild) => {
  500. childResolvers.set(step.shardIndex, resolveChild);
  501. }),
  502. terminate,
  503. };
  504. },
  505. writeManifest: vi.fn(),
  506. printManifest: vi.fn(),
  507. });
  508. await vi.waitFor(() => expect(childResolvers.size).toBe(2));
  509. signalSource.emit("SIGTERM");
  510. await expect(execution).rejects.toMatchObject({
  511. message: expect.stringContaining("parent received SIGTERM"),
  512. manifest: expect.objectContaining({ interruptedBySignal: "SIGTERM" }),
  513. });
  514. expect(terminates).toHaveLength(2);
  515. expect(terminates.every((terminate) => terminate.mock.calls.length === 1)).toBe(true);
  516. expect(signalSource.listenerCount("SIGINT")).toBe(0);
  517. expect(signalSource.listenerCount("SIGTERM")).toBe(0);
  518. });
  519. it("separates the single-shard default from the fixed 10-shard performance entry", () => {
  520. const desktopPackage = JSON.parse(
  521. readFileSync(resolve(process.cwd(), "packages/desktop/package.json"), "utf-8"),
  522. ) as { scripts: Record<string, string> };
  523. const rootPackage = JSON.parse(
  524. readFileSync(resolve(process.cwd(), "package.json"), "utf-8"),
  525. ) as { scripts: Record<string, string> };
  526. expect(desktopPackage.scripts["pretest:e2e"]).toBe(
  527. "pnpm --filter @zcode/e2e-report build:node",
  528. );
  529. expect(desktopPackage.scripts["test:e2e"]).toBe("node scripts/run-windows-e2e-shards.mjs");
  530. expect(rootPackage.scripts["test:e2e"]).toBe("pnpm --filter @zcode/desktop test:e2e");
  531. expect(desktopPackage.scripts["test:e2e:windows:sharded"]).toBe("pnpm test:e2e -- --shards=10");
  532. expect(rootPackage.scripts["test:e2e:windows:sharded"]).toBe(
  533. "pnpm --filter @zcode/desktop test:e2e:windows:sharded",
  534. );
  535. });
  536. });