Skip to content

test(cli): build expected codex path with path.join for Windows - #1803

Open
leucds2018-hub wants to merge 1 commit into
tashfeenahmed:mainfrom
leucds2018-hub:fix/cli-codex-detect-test-portable
Open

leucds2018-hub wants to merge 1 commit into
tashfeenahmed:mainfrom
leucds2018-hub:fix/cli-codex-detect-test-portable

Conversation

@leucds2018-hub

Copy link
Copy Markdown

Problem

cli/src/detect.test.ts asserts a POSIX literal:

expect(found).toEqual({ kind: 'cli', cliPath: '/opt/tools/bin/codex' });

but executableOnPath builds the candidate with path.join(dir, name), which uses the host separator. On Windows the test fails:

FAIL src/detect.test.ts > detectChatGptClient > detects the CLI when a codex binary is on PATH
AssertionError: expected { kind: 'cli', …(1) } to deeply equal { kind: 'cli', …(1) }
-   "cliPath": "/opt/tools/bin/codex",
+   "cliPath": "\\opt\\tools\\bin\\codex",

The implementation is correct — path.join is the right call at runtime — so only the assertion is platform-specific. Effect: npm test fails for Windows contributors in the cli workspace (178/179) even though the server suite is green, which makes the documented "keep the suite green" checklist impossible to satisfy locally.

Fix

Assert the path the same way the implementation builds it:

import path from 'node:path';

expect(found).toEqual({ kind: 'cli', cliPath: path.join('/opt/tools/bin', 'codex') });

path.posix.join(...) would also pass, but it pins the assertion to the opposite separator and would break again if the implementation changed, so joining with the host path is the accurate choice.

Verification

  • npx vitest run in cli/ on Windows 11: 179/179 passing (was 178/179)
  • npm run build (root): OK
  • npm test -w server: green
  • Scope: one test file, one assertion, no production code touched.

detect.test.ts asserted a POSIX literal ('/opt/tools/bin/codex') while executableOnPath joins PATH entries with the host separator, so the test failed on Windows with received '\opt\tools\bin\codex'.

Assert the path the same way the implementation builds it, so the suite is green on both separators.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant