| ... | ... | @@ -12,21 +12,17 @@ import * as TestClock from "effect/testing/TestClock"; |
| 12 | 12 | import { ChildProcessSpawner } from "effect/unstable/process"; |
| 13 | 13 | |
| 14 | 14 | import { |
| 15 | | buildWslNodeEnvPreamble, |
| 16 | 15 | buildWslRuntimeInstallScript, |
| 17 | 16 | buildWslRuntimeInvalidateScript, |
| 18 | 17 | buildWslRuntimePruneScript, |
| 19 | 18 | DesktopWslDistroListError, |
| 20 | 19 | formatMissingToolsReason, |
| 21 | | formatNodePtyProbeFailureReason, |
| 22 | | formatWslShellTransportFailureReason, |
| 23 | 20 | parseNodePath, |
| 24 | 21 | parseNodeVersion, |
| 25 | 22 | parseResolvedPath, |
| 26 | 23 | parseToolchainReport, |
| 27 | 24 | parseWslRuntimeRoot, |
| 28 | 25 | probeWslDistros, |
| 29 | | sanitizeWslRuntimeId, |
| 30 | 26 | } from "./DesktopWslEnvironment.ts"; |
| 31 | 27 | |
| 32 | 28 | const encoder = new TextEncoder(); |
| ... | ... | @@ -144,46 +140,19 @@ describe("probeWslDistros", () => { |
| 144 | 140 | }); |
| 145 | 141 | }); |
| 146 | 142 | |
| 147 | | describe("formatNodePtyProbeFailureReason", () => { |
| 148 | | it("identifies a packaged build that omitted the Linux node-pty prebuild", () => { |
| 149 | | const reason = formatNodePtyProbeFailureReason(4); |
| 150 | | |
| 151 | | expect(reason).toContain("packaged Linux node-pty binary was not included"); |
| 152 | | expect(reason).toContain("--wsl-prebuild"); |
| 153 | | }); |
| 154 | | |
| 155 | | it("leaves other node-pty load failures to the compatibility diagnostic", () => { |
| 156 | | expect(formatNodePtyProbeFailureReason(1)).toBeNull(); |
| 157 | | }); |
| 158 | | }); |
| 159 | | |
| 160 | | describe("formatWslShellTransportFailureReason", () => { |
| 161 | | it("distinguishes timeouts and spawn failures from normal shell exit codes", () => { |
| 162 | | expect(formatWslShellTransportFailureReason("timeout")).toContain("timed out"); |
| 163 | | expect(formatWslShellTransportFailureReason("spawn")).toContain("could not start wsl.exe"); |
| 164 | | expect(formatWslShellTransportFailureReason("process")).toContain("lost communication"); |
| 165 | | expect(formatWslShellTransportFailureReason(null)).toBeNull(); |
| 166 | | }); |
| 167 | | }); |
| 168 | | |
| 169 | | describe("buildWslNodeEnvPreamble", () => { |
| 170 | | it("passes the required Node engine range into the shared resolver", () => { |
| 171 | | const preamble = buildWslNodeEnvPreamble("^22.16 || ^23.11 || >=24.10"); |
| 172 | | |
| 173 | | expect(preamble).toContain("T3_NODE_ENGINE_RANGE='^22.16 || ^23.11 || >=24.10'"); |
| 174 | | expect(preamble.indexOf("T3_NODE_ENGINE_RANGE=")).toBeLessThan( |
| 175 | | preamble.lastIndexOf("ensure_remote_node_path || true"), |
| 176 | | ); |
| 177 | | }); |
| 178 | | |
| 179 | | it("keeps the shared resolver permissive when no Node engine range is provided", () => { |
| 180 | | expect(buildWslNodeEnvPreamble()).toContain("T3_NODE_ENGINE_RANGE=''"); |
| 181 | | }); |
| 182 | | }); |
| 183 | | |
| 184 | 143 | describe("WSL runtime cache", () => { |
| 185 | | it("sanitizes cache ids before interpolating them into Linux paths", () => { |
| 186 | | expect(sanitizeWslRuntimeId("1.2.3/x64; touch /tmp/nope")).toBe("1.2.3_x64__touch__tmp_nope"); |
| 144 | it.each([ |
| 145 | [ |
| 146 | "install", |
| 147 | (id: string) => buildWslRuntimeInstallScript("/runtime.tar.gz", id, "b".repeat(64)), |
| 148 | ], |
| 149 | ["prune", buildWslRuntimePruneScript], |
| 150 | ["invalidate", buildWslRuntimeInvalidateScript], |
| 151 | ] as const)("sanitizes cache ids in the %s script", (_, buildScript) => { |
| 152 | const runtimeId = "1.2.3/x64; touch /tmp/nope"; |
| 153 | const script = buildScript(runtimeId); |
| 154 | expect(script).toContain("/1.2.3_x64__touch__tmp_nope"); |
| 155 | expect(script).not.toContain(runtimeId); |
| 187 | 156 | }); |
| 188 | 157 | |
| 189 | 158 | it("installs through a temporary directory and only reuses valid completed caches", () => { |