返回 DeepSeek-Reasonix
desktop-windows-go-tests.test.mjs
根目录 / scripts / desktop-windows-go-tests.test.mjs
1 import assert from "node:assert/strict";
2 import { readFileSync } from "node:fs";
3 import test from "node:test";
4 import { conptyProbe, groups, historyTests, inventoryFromJSON, owners, testArgs, verifyInventory } from "./desktop-windows-go-tests.mjs";
5
6 test("every test prefix, example and fuzz seed has exactly one execution owner", () => {
7 const names = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"].map(letter => `Test${letter}Feature`);
8 names.push("Test", "Test_Compatibility", "Test中文", "Example", "ExampleController_Open", "FuzzSession", conptyProbe, ...Object.values(historyTests));
9 for (const name of names) assert.equal(owners(name).length, 1, name);
10 assert.deepEqual(owners("ExampleController_Open"), ["A-B"]);
11 assert.deepEqual(owners("FuzzSession"), ["A-B"]);
12 assert.deepEqual(owners(conptyProbe), ["conpty-probe"]);
13 const counts = verifyInventory(new Map(names.map(name => [name, name])));
14 assert.equal(Object.values(counts).reduce((sum, count) => sum + count, 0), names.length);
15 assert.throws(() => testArgs("missing"), /Unknown/);
16 assert.throws(() => verifyInventory(new Map()), /Empty/);
17 });
18
19 test("all historical releases have an independent bounded execution owner", () => {
20 for (const [group, name] of Object.entries(historyTests)) {
21 assert.deepEqual(owners(name), [group]);
22 assert.deepEqual(testArgs(group, true), ["test", "-race", "-timeout=25m", "-run", `^${name}$`, "./..."]);
23 }
24 const source = readFileSync(new URL("../.github/workflows/ci.yml", import.meta.url), "utf8");
25 const ordinary = source.match(/\n desktop-go:\n([\s\S]*?)(?=\n [a-z][a-z0-9-]*:|$)/)?.[1];
26 assert.match(ordinary, /node \.\.\/scripts\/desktop-windows-go-tests\.mjs --all/);
27 });
28
29 test("inventory keeps same-named tests from different packages and rejects missing output", () => {
30 const output = ["pkg/a", "pkg/b"].map(Package => JSON.stringify({ Action: "output", Package, Output: "TestActive\n" })).join("\n");
31 assert.equal(inventoryFromJSON(output).size, 2);
32 assert.throws(() => inventoryFromJSON(""), /no desktop test inventory/);
33 });
34
35 test("URI upgrade and preview regressions have exactly one Windows execution owner", () => {
36 for (const name of ["TestWindowsUpgradeFixtureMigratesLegacyAndRestarts", "TestDesktopV1UpgradeBacksUpTopicWALAndRetriesWithoutDuplicateImport",
37 "TestChatFileReferencePreservesRawFilenameCharacters", "TestResolveMarkdownImageSelectsPercentAndSpaceNamesExactly"]) {
38 assert.equal(owners(name).length, 1, name);
39 }
40 });
41
42 test("CI runs all groups separately and retains the aggregate and native probe", () => {
43 const source = readFileSync(new URL("../.github/workflows/ci.yml", import.meta.url), "utf8");
44 const matrixJob = source.match(/\n desktop-windows-go-group:\n([\s\S]*?)(?=\n [a-z][a-z0-9-]*:|$)/)?.[1];
45 assert.ok(matrixJob);
46 const matrix = matrixJob.match(/group: \[([^\]]+)\]/)[1].split(",").map(value => value.trim());
47 assert.deepEqual(matrix, groups);
48 const raceJob = source.match(/\n desktop-go-race:\n([\s\S]*?)(?=\n [a-z][a-z0-9-]*:|$)/)?.[1];
49 assert.ok(raceJob);
50 assert.deepEqual(raceJob.match(/group: \[([^\]]+)\]/)[1].split(",").map(value => value.trim()), groups);
51 assert.match(matrixJob, /fail-fast: false/);
52 assert.match(matrixJob, /actions\/setup-node@[0-9a-f]{40} # v7\b/);
53 assert.doesNotMatch(matrixJob, /cache: pnpm/, "Go-only groups must not cache a pnpm store they never create");
54 assert.match(matrixJob, /run: node \.\.\/scripts\/desktop-windows-go-tests\.mjs \$\{\{ matrix.group \}\}/);
55 assert.match(matrixJob, /run: go test -run '\^TestWindowsTerminalProcessConPTYSmoke\$' \./);
56 const aggregate = source.match(/\n desktop-windows-go:\n([\s\S]*?)(?=\n [a-z][a-z0-9-]*:|$)/)?.[1];
57 assert.match(aggregate, /needs: \[changes, desktop-prepare, desktop-windows-go-group\]/);
58 assert.match(aggregate, /test "\$GROUP_RESULT" = success/);
59 const releaseControl = source.match(/\n release-control:\n([\s\S]*?)(?=\n [a-z][a-z0-9-]*:|$)/)?.[1];
60 assert.ok(releaseControl, "release-control job must still exist");
61 assert.match(releaseControl, /node --test[\s\S]*?scripts\/desktop-windows-go-tests\.test\.mjs/);
62 });
63
63 lines Plain Text