Skip to content

Commit 09f8e5e

Browse files
lidge-junluvs01andrew05060414
authored
test: fix two Windows path regressions in service tests (#6202)
* test(service): resolve the census child import with repoPath on Windows new URL(..., import.meta.url).pathname yields /D:/a/... on Windows, so the spawned census and delegate children could not import serving-runtimes.ts. Co-authored-by: luvs01 <[email protected]> * test(service): build the systemd multishell fixture with POSIX paths path.join and the host delimiter produced backslash paths and ;-joined PATHs on Windows runners, so the systemd unit assertion could never match. Co-authored-by: Andrew <[email protected]> --------- Co-authored-by: luvs01 <[email protected]> Co-authored-by: Andrew <[email protected]>
1 parent 8d53c21 commit 09f8e5e

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎tests/config/serving-runtimes.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from "../../src/config/serving-runtimes";
1919
import { buildWinswXml } from "../../src/lib/winsw";
2020
import { buildWindowsServiceScript } from "../../src/service/windows-taskxml";
21+
import { repoPath } from "../helpers/repo-root";
2122

2223
const dirs: string[] = [];
2324

@@ -88,7 +89,7 @@ describe("serving runtime census", () => {
8889

8990
test("concurrent process writers preserve both commands", async () => {
9091
const dir = freshDir();
91-
const source = new URL("../../src/config/serving-runtimes.ts", import.meta.url).pathname;
92+
const source = repoPath("src", "config", "serving-runtimes.ts");
9293
const script = join(dir, "writer.ts");
9394
writeFileSync(script, `import { recordServingRuntime } from ${JSON.stringify(source)};
9495
recordServingRuntime({ command: [process.argv[3]], version: "2.68.0", servedAt: new Date().toISOString() }, process.argv[2]);
@@ -322,7 +323,7 @@ describe("deferToNewerServiceRuntime", () => {
322323
test("a real child that marks bind propagates a later nonzero exit", async () => {
323324
const dir = freshDir();
324325
const script = join(dir, "ready-child.ts");
325-
const source = new URL("../../src/config/serving-runtimes.ts", import.meta.url).pathname;
326+
const source = repoPath("src", "config", "serving-runtimes.ts");
326327
writeFileSync(script, `import { markDelegatedServiceReady } from ${JSON.stringify(source)};
327328
markDelegatedServiceReady();
328329
process.exit(42);

‎tests/service/service-multishell-path.test.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, test } from "bun:test";
2-
import { delimiter, join } from "node:path";
2+
import { posix } from "node:path";
33
import { buildPlist, buildUnit, buildWindowsServiceScript, repairService, stableLauncherEntry } from "../../src/service";
44
import { buildWinswXml } from "../../src/lib/winsw";
55
import { filterTransientServicePath, isTransientServiceLauncherPath, serviceLauncherPathDiagnostic } from "../../src/service/state";
@@ -17,20 +17,24 @@ describe("shell-scoped service paths", () => {
1717
});
1818

1919
test("skips a recorded fnm launcher and removes its directory from systemd PATH", () => {
20-
const temporaryBin = join("/tmp", "fnm_multishells", "shell-1", "bin");
20+
// A systemd unit is POSIX on every host, so the fixture is too: on a Windows runner the
21+
// host path module and delimiter would produce "\\opt\\..." paths and ";"-joined PATHs.
22+
const temporaryBin = posix.join("/tmp", "fnm_multishells", "shell-1", "bin");
2123
const durableBin = "/opt/opencodex/bin";
22-
const temporaryLauncher = join(temporaryBin, "ocx");
23-
const durableLauncher = join(durableBin, "ocx");
24+
const temporaryLauncher = posix.join(temporaryBin, "ocx");
25+
const durableLauncher = posix.join(durableBin, "ocx");
2426
const launcher = stableLauncherEntry({
2527
state: { launcherPath: temporaryLauncher } as never,
26-
env: { PATH: [temporaryBin, durableBin].join(delimiter) },
28+
env: { PATH: [temporaryBin, durableBin].join(":") },
29+
pathDelimiter: ":",
30+
platform: "linux",
2731
isExecutableFile: candidate => candidate === temporaryLauncher || candidate === durableLauncher,
2832
});
2933
expect(launcher).toBe(durableLauncher);
3034

3135
const oldPath = process.env.PATH;
3236
try {
33-
process.env.PATH = [temporaryBin, durableBin].join(delimiter);
37+
process.env.PATH = [temporaryBin, durableBin].join(":");
3438
const unit = buildUnit([], { launcher, runtime: { path: "/opt/opencodex/bun", source: "bundled", overrideEnv: "OPENCODEX_BUN_PATH" } });
3539
expect(unit).not.toContain("fnm_multishells");
3640
expect(unit).toContain(durableLauncher);

0 commit comments

Comments
 (0)