test: normalize paths in OPENCLAW_HOME tests for cross-platform support (#12212)

* test: normalize paths in OPENCLAW_HOME tests for cross-platform support

* test: normalize paths in Nix integration tests for cross-platform support

* test: remove unnecessary Windows skip from pi-embedded-runner test

* test: fix nix integration tests for path.resolve behavior
This commit is contained in:
max
2026-02-08 17:21:31 -08:00
committed by GitHub
parent 456bd58740
commit 53a1ac36f5
4 changed files with 67 additions and 77 deletions
@@ -49,37 +49,33 @@ describe("Nix integration (U3, U5, U9)", () => {
});
});
// Skip on Windows: these tests use Unix-style paths that only make sense on Nix/Unix
it.skipIf(process.platform === "win32")(
"STATE_DIR respects OPENCLAW_HOME when state override is unset",
async () => {
await withEnvOverride(
{ OPENCLAW_HOME: "/custom/home", OPENCLAW_STATE_DIR: undefined },
async () => {
const { STATE_DIR } = await import("./config.js");
expect(STATE_DIR).toBe(path.resolve("/custom/home/.openclaw"));
},
);
},
);
it("STATE_DIR respects OPENCLAW_HOME when state override is unset", async () => {
const customHome = path.join(path.sep, "custom", "home");
await withEnvOverride(
{ OPENCLAW_HOME: customHome, OPENCLAW_STATE_DIR: undefined },
async () => {
const { STATE_DIR } = await import("./config.js");
expect(STATE_DIR).toBe(path.join(path.resolve(customHome), ".openclaw"));
},
);
});
// Skip on Windows: these tests use Unix-style paths that only make sense on Nix/Unix
it.skipIf(process.platform === "win32")(
"CONFIG_PATH defaults to OPENCLAW_HOME/.openclaw/openclaw.json",
async () => {
await withEnvOverride(
{
OPENCLAW_HOME: "/custom/home",
OPENCLAW_CONFIG_PATH: undefined,
OPENCLAW_STATE_DIR: undefined,
},
async () => {
const { CONFIG_PATH } = await import("./config.js");
expect(CONFIG_PATH).toBe(path.resolve("/custom/home/.openclaw/openclaw.json"));
},
);
},
);
it("CONFIG_PATH defaults to OPENCLAW_HOME/.openclaw/openclaw.json", async () => {
const customHome = path.join(path.sep, "custom", "home");
await withEnvOverride(
{
OPENCLAW_HOME: customHome,
OPENCLAW_CONFIG_PATH: undefined,
OPENCLAW_STATE_DIR: undefined,
},
async () => {
const { CONFIG_PATH } = await import("./config.js");
expect(CONFIG_PATH).toBe(
path.join(path.resolve(customHome), ".openclaw", "openclaw.json"),
);
},
);
});
it("CONFIG_PATH defaults to ~/.openclaw/openclaw.json when env not set", async () => {
await withEnvOverride(