fix(tests): resolve /tmp symlink for macOS test compatibility#195
Merged
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
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 callst.TempDir()and thenfilepath.EvalSymlinks(...). - Replace all direct
t.TempDir()usage in the test file withresolvedTempDir(t)to avoid/tmpvs/private/tmpmismatches on macOS.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolvedTempDir(t)helper that wrapst.TempDir()withfilepath.EvalSymlinkst.TempDir()calls in the test file withresolvedTempDir(t)to prevent future regressionsRoot cause
On macOS,
/tmpis a symlink to/private/tmp. Go'st.TempDir()returns/tmp/Test...but production code resolves symlinks (viafilepath.EvalSymlinks,os.Executable, oros.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
TestRunDoctorFixUsesConfigVersionForBackendInstallsInsideSourceCheckoutTestRunUpgradeUpdatesConfigVersionAndInstallsMatchingBackendsTestRunUpgradeUsesLocalSourcesInsideSourceCheckoutTestRunInstallCLICommandTestRunInstallCLICommandInstallsAllLanguagesByDefaultTestRunInstallCLIUsesLocalSourcesForDevWrapperTestRunInstallCLIUsesLocalSourcesInsideSourceCheckoutForReleaseWrapperTestRunInstallCLIUsesPinnedReleaseVersionsInsideSourceCheckoutTestRunInstallCLIUsesLocalSourcesFromNestedPackageDirForReleaseWrapperTestResolveBackendCommandAddsAnsibleLanguageFlagTestResolveBackendCommandAddsTerraformLanguageFlagTestRunMonorepoInstallExecutesEachBackendAtRepoRootTestRunSingleLanguageInstallReinstallsBackendWhenVersionMismatchesTestEnsureInstalledUsesPinnedVersionWhenBackendVersionDiffersTest plan
go test ./...reportsokresolvedTempDiris a no-op on Linux (no symlinks to resolve), so CI behavior is unchanged🤖 Generated with Claude Code