From 5a57d087405b2c639adf30a14385a0d93a57f922 Mon Sep 17 00:00:00 2001 From: luvs01 <27862058+luvs01@users.noreply.github.com> Date: Sun, 13 Sep 2026 08:11:17 +0900 Subject: [PATCH] test(devin-cli): anchor the empty-data-dir fallback at the host home The fallback resolves against the real home directory, so asserting a leading slash only held on a POSIX host and failed the Windows lane. Anchor both branches at homedir(), and normalize the anchor for the win32 branch because win32.join rewrites a POSIX host home such as /Users/runner to \Users\runner. --- tests/providers/devin-cli-login.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/providers/devin-cli-login.test.ts b/tests/providers/devin-cli-login.test.ts index 766e28eca2..5871a8ae08 100644 --- a/tests/providers/devin-cli-login.test.ts +++ b/tests/providers/devin-cli-login.test.ts @@ -1,4 +1,6 @@ import { describe, expect, test } from "bun:test"; +import { homedir } from "node:os"; +import { win32 } from "node:path"; import { DEVIN_CLI_CREDENTIALS_ENV, devinCliCredentialsPath, @@ -149,13 +151,21 @@ describe("devin-cli credential path and read bounds", () => { // directory the proxy was started in, and a planted file there would import // as the operator's own CLI session. // The fallback reads the real home directory rather than env.HOME, so the - // assertion is on shape: absolute, and under the home data dir. + // assertion is on shape: anchored at that home directory, and under its data + // dir. Anchoring is what proves the path is not cwd-relative; asserting a + // leading "/" instead would only hold when the HOST is POSIX, because + // `homedir()` returns `C:\\Users\\` on Windows no matter which + // platform the resolver is asked about. for (const empty of ["", " "]) { const resolved = devinCliCredentialsPath({ HOME: "/home/u", XDG_DATA_HOME: empty }, "linux"); - expect(resolved.startsWith("/")).toBe(true); + expect(resolved.startsWith(homedir())).toBe(true); expect(resolved.endsWith("/.local/share/devin/credentials.toml")).toBe(true); } const win = devinCliCredentialsPath({ APPDATA: "" }, "win32"); + // The win32 branch joins with win32 separators, so a POSIX host home such as + // `/Users/runner` comes back as `\\Users\\runner`. Normalize the anchor the + // same way rather than comparing a host-shaped string against it. + expect(win.startsWith(win32.join(homedir()))).toBe(true); expect(win.endsWith("AppData\\Roaming\\devin\\credentials.toml")).toBe(true); expect(win.startsWith("devin")).toBe(false); });