Skip to content

fix(tests): resolve /tmp symlink for macOS test compatibility#195

Merged
markcallen merged 1 commit into
mainfrom
fix/macos-tmp-symlink-test-failures
May 26, 2026
Merged

fix(tests): resolve /tmp symlink for macOS test compatibility#195
markcallen merged 1 commit into
mainfrom
fix/macos-tmp-symlink-test-failures

Conversation

@markcallen

Copy link
Copy Markdown
Contributor

Summary

  • Add resolvedTempDir(t) helper that wraps t.TempDir() with filepath.EvalSymlinks
  • Replace all t.TempDir() calls in the test file with resolvedTempDir(t) to prevent future regressions
  • Fixes 14 tests that fail locally on macOS but pass in Linux CI

Root cause

On macOS, /tmp is a symlink to /private/tmp. Go's t.TempDir() returns /tmp/Test... but production code resolves symlinks (via filepath.EvalSymlinks, os.Executable, or os.Getwd) producing /private/tmp/Test.... Tests that compare command strings built from temp dir paths fail because one side has the resolved path and the other does not.

Tests fixed

  • TestRunDoctorFixUsesConfigVersionForBackendInstallsInsideSourceCheckout
  • TestRunUpgradeUpdatesConfigVersionAndInstallsMatchingBackends
  • TestRunUpgradeUsesLocalSourcesInsideSourceCheckout
  • TestRunInstallCLICommand
  • TestRunInstallCLICommandInstallsAllLanguagesByDefault
  • TestRunInstallCLIUsesLocalSourcesForDevWrapper
  • TestRunInstallCLIUsesLocalSourcesInsideSourceCheckoutForReleaseWrapper
  • TestRunInstallCLIUsesPinnedReleaseVersionsInsideSourceCheckout
  • TestRunInstallCLIUsesLocalSourcesFromNestedPackageDirForReleaseWrapper
  • TestResolveBackendCommandAddsAnsibleLanguageFlag
  • TestResolveBackendCommandAddsTerraformLanguageFlag
  • TestRunMonorepoInstallExecutesEachBackendAtRepoRoot
  • TestRunSingleLanguageInstallReinstallsBackendWhenVersionMismatches
  • TestEnsureInstalledUsesPinnedVersionWhenBackendVersionDiffers

Test plan

  • All 14 previously failing tests now pass on macOS
  • Full test suite passes: go test ./... reports ok
  • resolvedTempDir is a no-op on Linux (no symlinks to resolve), so CI behavior is unchanged

🤖 Generated with Claude Code

On macOS, /tmp is a symlink to /private/tmp. When tests use t.TempDir()
for path comparisons, the raw path (/tmp/...) does not match what the
production code produces after resolving symlinks (/private/tmp/...),
causing 14 tests to fail locally on macOS while passing in Linux CI.

Add a resolvedTempDir(t) helper that wraps t.TempDir() with
filepath.EvalSymlinks, and use it throughout the test file so path
string comparisons work on both platforms.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 26, 2026 19:03
@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the CLI wrapper’s test suite (cli/ballast/main_test.go) to be macOS-compatible when temp directories are involved in path/string comparisons, by ensuring temp paths are consistently symlink-resolved.

Changes:

  • Introduce a resolvedTempDir(t) helper that calls t.TempDir() and then filepath.EvalSymlinks(...).
  • Replace all direct t.TempDir() usage in the test file with resolvedTempDir(t) to avoid /tmp vs /private/tmp mismatches on macOS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@markcallen markcallen merged commit 09ade2e into main May 26, 2026
40 checks passed
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.

2 participants