Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

windows-wsl-ci-contract.test.mjs

61 lines2.8 KB

1import assert from "node:assert/strict";
2import { readFileSync } from "node:fs";
3import test from "node:test";
4​
5const ci = readFileSync(new URL("../.github/workflows/ci.yml", import.meta.url), "utf8");
6const bootstrap = readFileSync(new URL("./bootstrap-wsl2-ci.ps1", import.meta.url), "utf8");
7const smoke = readFileSync(new URL("./smoke-wsl2-native-runtime.ps1", import.meta.url), "utf8");
8const integration = readFileSync(
9 new URL("../apps/desktop/src/wsl/DesktopWslEnvironment.windows.integration.test.ts", import.meta.url),
10 "utf8",
11);
12const stage = readFileSync(new URL("./stage-wsl-ci-node-pty.mjs", import.meta.url), "utf8");
13​
14test("CI has merge-gatable native Windows and real WSL2 jobs", () => {
15 assert.match(ci, /\n windows_native:\n/);
16 assert.match(ci, /\n windows_wsl2_integration:\n/);
17 assert.match(ci, /runs-on: windows-2025/);
18 assert.match(ci, /vp run --filter @t3tools\/desktop test/);
19 assert.match(ci, /vp run build:desktop/);
20 assert.match(ci, /DesktopWslEnvironment\.windows\.integration\.test\.ts/);
21});
22​
23test("WSL2 integration reuses an ABI-audited runtime and two real distros", () => {
24 assert.match(ci, /\n wsl_native_ci:\n/);
25 assert.match(ci, /image: ubuntu:22\.04/);
26 assert.match(ci, /--max-glibc 2\.35/);
27 assert.match(ci, /ci-wsl-native-runtime-x64/);
28 assert.match(ci, /stage-wsl-ci-node-pty\.mjs --server-root apps\/server/);
29 assert.match(ci, /bootstrap-wsl2-ci\.ps1 -Distros Ubuntu-24\.04,Debian/);
30 assert.match(ci, /smoke-wsl2-native-runtime\.ps1 -RuntimeDir \.\/wsl-prebuild -Distros Ubuntu-24\.04,Debian/);
31});
32​
33test("WSL bootstrap enforces WSL2 and deliberately changes the default distro", () => {
34 assert.match(bootstrap, /--set-default-version", "2"/);
35 assert.match(bootstrap, /--set-version", \$distro, "2"/);
36 assert.match(bootstrap, /--set-default", \$Distros\[1\]/);
37 assert.match(bootstrap, /useradd -m -s \/bin\/bash t3ci/);
38 assert.match(bootstrap, /default=t3ci/);
39 assert.match(bootstrap, /T3CODE_WSL_EXPECTED_DEFAULT_DISTRO/);
40});
41​
42test("real WSL integration gates the repaired production boundaries", () => {
43 assert.match(integration, /environment\.probeDistros/);
44 assert.match(integration, /environment\.windowsToWslPath/);
45 assert.match(integration, /environment\.ensureNodePty/);
46 assert.match(stage, /t3code-wsl-node-pty\.json/);
47 assert.match(stage, /nodePtyVersion/);
48 assert.match(stage, /abiBaseline/);
49 assert.match(integration, /printf corrupted/);
50 assert.match(integration, /environment\.allocateTcpPort/);
51 assert.match(integration, /EADDRINUSE/);
52 assert.match(integration, /fetchHealth/);
53});
54​
55test("native smoke executes the audited Node and Linux-native modules inside WSL", () => {
56 assert.match(smoke, /smoke-wsl-native-runtime\.mjs/);
57 assert.match(smoke, /--node-runtime/);
58 assert.match(smoke, /--node-pty/);
59 assert.match(smoke, /--manifest/);
60 assert.match(smoke, /chmod 0755/);
61});