返回 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, 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);
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("inventory keeps same-named tests from different packages and rejects missing output", () => {
20 const output = ["pkg/a", "pkg/b"].map(Package => JSON.stringify({ Action: "output", Package, Output: "TestActive\n" })).join("\n");
21 assert.equal(inventoryFromJSON(output).size, 2);
22 assert.throws(() => inventoryFromJSON(""), /no desktop test inventory/);
23 });
24
25 test("URI upgrade and preview regressions have exactly one Windows execution owner", () => {
26 for (const name of ["TestWindowsUpgradeFixtureMigratesLegacyAndRestarts", "TestDesktopV1UpgradeBacksUpTopicWALAndRetriesWithoutDuplicateImport",
27 "TestChatFileReferencePreservesRawFilenameCharacters", "TestResolveMarkdownImageSelectsPercentAndSpaceNamesExactly"]) {
28 assert.equal(owners(name).length, 1, name);
29 }
30 });
31
32 test("CI runs all groups separately and retains the aggregate and native probe", () => {
33 const source = readFileSync(new URL("../.github/workflows/ci.yml", import.meta.url), "utf8");
34 const matrixJob = source.match(/\n desktop-windows-go-group:\n([\s\S]*?)(?=\n [a-z][a-z0-9-]*:|$)/)?.[1];
35 assert.ok(matrixJob);
36 const matrix = matrixJob.match(/group: \[([^\]]+)\]/)[1].split(",").map(value => value.trim());
37 assert.deepEqual(matrix, groups);
38 assert.match(matrixJob, /fail-fast: false/);
39 assert.match(matrixJob, /actions\/setup-node@v7/);
40 assert.doesNotMatch(matrixJob, /cache: pnpm/, "Go-only groups must not cache a pnpm store they never create");
41 assert.match(matrixJob, /run: node \.\.\/scripts\/desktop-windows-go-tests\.mjs \$\{\{ matrix.group \}\}/);
42 assert.match(matrixJob, /run: go test -run '\^TestWindowsTerminalProcessConPTYSmoke\$' \./);
43 const aggregate = source.match(/\n desktop-windows-go:\n([\s\S]*?)(?=\n [a-z][a-z0-9-]*:|$)/)?.[1];
44 assert.match(aggregate, /needs: \[changes, desktop-prepare, desktop-windows-go-group\]/);
45 assert.match(aggregate, /test "\$GROUP_RESULT" = success/);
46 const releaseControl = source.match(/\n release-control:\n([\s\S]*?)(?=\n [a-z][a-z0-9-]*:|$)/)?.[1];
47 assert.ok(releaseControl, "release-control job must still exist");
48 assert.match(releaseControl, /node --test[\s\S]*?scripts\/desktop-windows-go-tests\.test\.mjs/);
49 });
50
50 lines Plain Text