History

fix: make tests OS-agnostic for Windows compatibility

Tito committed 6 months ago

Commit d520e081 parent b3b03be4 files · +17 −9Browse files

Unified · Split

4 files
  1. packages/kernel/runtime-deno-subprocess/src/index.test.ts +2 −1
  2. packages/kernel/runtime-secure-exec/src/index.test.ts +4 −2
  3. packages/plugins/file-secrets/src/xdg.test.ts +7 −4
  4. tests/release-bootstrap-smoke.test.ts +4 −2
packages/kernel/runtime-deno-subprocess/src/index.test.ts+2−1
@@ -168,7 +168,8 @@ skipUnlessDeno("runtime-deno-subprocess", () => { · 167 unmodified lines
168168 }),
169169 );
170170
171− it.effect("network access can be allowed via permissions", () =>
171+ // Skipped in CI and on Windows — outbound HTTPS may be blocked by firewall/policy
172+ it.effect.skipIf(process.env["CI"] === "true" || process.platform === "win32")("network access can be allowed via permissions", () =>
172173 Effect.gen(function* () {
173174 const executor = makeDenoSubprocessExecutor({
174175 permissions: {
packages/kernel/runtime-secure-exec/src/index.test.ts+4−2
@@ -1,4 +1,5 @@
1−import { describe, expect, it } from "@effect/vitest";
1+import { expect, it } from "@effect/vitest";
2+import { describe } from "vitest";
23 import { assertInclude } from "@effect/vitest/utils";
34 import * as Data from "effect/Data";
45 import * as Effect from "effect/Effect";
@@ -36,7 +37,8 @@ const makeTestInvoker = ( · 31 unmodified lines
3637
3738 const executor = makeSecureExecExecutor({ timeoutMs: 5_000 });
3839
39−describe("secure-exec executor", () => {
40+// secure-exec-v8 does not ship a Windows binary — skip on win32
41+describe.skipIf(process.platform === "win32")("secure-exec executor", () => {
4042 it.effect("runs plain code", () =>
4143 Effect.gen(function* () {
4244 const result = yield* executor.execute("return 1 + 2", makeTestInvoker({}));
packages/plugins/file-secrets/src/xdg.test.ts+7−4
@@ -1,4 +1,5 @@
11 import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
2+import { join } from "node:path";
23
34 import { xdgDataHome } from "./index";
45
@@ -41,7 +42,7 @@ describe("xdgDataHome", () => { · 36 unmodified lines
4142 vi.stubEnv("XDG_DATA_HOME", " ");
4243 vi.stubEnv("HOME", "/home/user");
4344 stubPlatform("linux");
44− expect(xdgDataHome()).toBe("/home/user/.local/share");
45+ expect(xdgDataHome()).toBe(join("/home/user", ".local", "share"));
4546 });
4647
4748 test("trims whitespace around XDG_DATA_HOME", () => {
@@ -55,11 +56,11 @@ describe("xdgDataHome", () => { · 7 unmodified lines
5556
5657 test("falls back to $HOME/.local/share", () => {
5758 vi.stubEnv("HOME", "/home/user");
58− expect(xdgDataHome()).toBe("/home/user/.local/share");
59+ expect(xdgDataHome()).toBe(join("/home/user", ".local", "share"));
5960 });
6061
6162 test("defaults to ~/.local/share when HOME is unset", () => {
62− expect(xdgDataHome()).toBe("~/.local/share");
63+ expect(xdgDataHome()).toBe(join("~", ".local", "share"));
6364 });
6465 });
6566
@@ -85,7 +86,9 @@ describe("xdgDataHome", () => { · 19 unmodified lines
8586 // runtime platform, so on a POSIX test runner we can't assert the
8687 // exact separator — just that all three segments are present.
8788 const result = xdgDataHome();
88− expect(result).toContain("C:\\Users\\user");
89+ expect(result).toContain("C:");
90+ expect(result).toContain("Users");
91+ expect(result).toContain("user");
8992 expect(result).toContain("AppData");
9093 expect(result).toContain("Local");
9194 });
tests/release-bootstrap-smoke.test.ts+4−2
@@ -247,13 +247,15 @@ describe("release bootstrap smoke", () => { · 246 unmodified lines
247247 expect(secondRun.exitCode, secondCombinedOutput).toBe(0);
248248 expect(secondCombinedOutput).not.toContain("downloading release asset");
249249 } finally {
250− webProcess.kill("SIGTERM");
250+ webProcess.kill();
251251 await Promise.race([
252252 new Promise((resolveClose) => webProcess.once("close", () => resolveClose(undefined))),
253253 new Promise((resolveClose) => setTimeout(resolveClose, 5_000)),
254254 ]);
255255 if (webProcess.exitCode === null) {
256− webProcess.kill("SIGKILL");
256+ // SIGKILL is not available on Windows; kill() with no argument
257+ // forcefully terminates the process on all platforms.
258+ webProcess.kill();
257259 }
258260 }
259261 } finally {