nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] gh-pr-worktree tests fail on macOS because the temp dir is a symlink

Open me-adityaraj8 opened this issue 1 month ago • 2 comments

Description

Two tests in source/commands/gh-pr-worktree.spec.ts fail on macOS on a clean main:

  • entering the worktree makes it the session cwd and project root
  • real Git worktree makes relative file reads use the PR head and preserves a dirty launch checkout

On macOS tmpdir() is /var/folders/..., which is a symlink to /private/var/folders/.... After process.chdir, process.cwd() returns the resolved path, so the t.is path comparisons don't match.

Environment

  • OS: macOS 27.0
  • Node version: v24.1.0
  • Nanocoder version: main

Steps to Reproduce

pnpm build
npx ava source/commands/gh-pr-worktree.spec.ts

Expected Behavior

All 14 tests pass.

Actual Behavior

2 tests fail:

- '/private/var/folders/.../nanocoder-pr-test-...-pr-42'
+ '/var/folders/.../nanocoder-pr-test-...-pr-42'

With TMPDIR=$(realpath $TMPDIR)/ all 14 pass.

Suggested fix

Resolve the fixture roots with realpathSync(mkdtempSync(...)) (lines 20 and 256). Happy to send a PR for this.

me-adityaraj8 avatar Oct 23 '26 05:10 me-adityaraj8

I can take this issue. The reproduction and suggested fixture-path normalization are clear; I’ll prepare a small regression-focused PR and rely on the project’s checks for validation.

Vamsi-2581 avatar Oct 23 '26 05:10 Vamsi-2581

Fixed by ef41e8a on main — thanks @will-lamerton! Closing.

me-adityaraj8 avatar Oct 23 '26 14:10 me-adityaraj8