Skip to content

test: resolveClientCommand codex/claude test is environment-dependent (fails when codex/claude live in /usr/bin) #642

Description

@ranxianglei

来源: 分析 #641(PR review)时发现

Problem

tests/launcher.test.ts:1069resolveClientCommand: codex/claude resolve to themselves asserts the not-on-PATH fallback:

assert.deepEqual(resolveClientCommand("codex", { PATH: "/usr/bin" }), {
    command: "codex",
    prefixArgs: [],
});
assert.deepEqual(resolveClientCommand("claude", { PATH: "/usr/bin" }), {
    command: "claude",
    prefixArgs: [],
});

It hard-codes /usr/bin as a PATH that does NOT contain codex/claude. On any machine where codex or claude is installed in /usr/bin (common for this project's target users — developers who run these CLIs), the test fails:

AssertionError: Expected values to be strictly deep-equal:
  {
+   command: '/usr/bin/codex',
-   command: 'codex',
  }

Impact

  • npm test is red on any dev machine with codex/claude in /usr/bin (observed: sandbox with /usr/bin/codex installed → 1 failure out of 1252; pre-existing on master, not PR-specific).
  • CI stays green (GitHub ubuntu runners don't ship codex/claude), so the breakage is only visible locally.
  • No product impact — resolveOnPath (src/launcher.ts) itself is correct; only the test's environment assumption is wrong.

Suggested fix

Make the test hermetic, following the pattern of the codebuddy tests in #641:

  • not-on-PATH case: pass a PATH pointing at an empty temp dir.
  • on-PATH case: create a fake codex/claude executable in a temp bin dir and assert the absolute path is returned.

Minor severity — test hygiene only.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions