Make acceptance sethome export an absolute HOME (cross-platform)#5266
Merged
Conversation
sethome exported HOME (and USERPROFILE) as the relative path the caller passed in (typically "./home"). The SDK expands `~/.databrickscfg` against $HOME at lookup time, so the moment a test cd's into a child directory, the cfg "disappears": helpers like databrickscfg.GetConfiguredDefaultProfile silently return "" because the relative path no longer points at a real file. That made it easy to write tests that look like they exercise default_profile resolution but actually only succeed because the cfg lookup short-circuits. Resolve $1 to an absolute path with `cd && pwd` (portable on macOS/Linux/Windows-MSYS) before exporting. With this fix, the acceptance/auth/bundle_default_profile "workspace.profile pinned" sub-case correctly fails when the Workspace.Profile == "" guard in cmd/root/bundle.go configureProfile is removed; previously it passed either way. Output for the same directory's "Bundle with workspace.host" sub-case also changes: with the cfg now reachable from the bundle subdir, the SDK's host-based lookup finds the matching profile and validate succeeds instead of failing with "default auth: cannot configure default credentials". Co-authored-by: Isaac
81d9297 changed sethome to export an absolute HOME so the SDK can locate ~/.databrickscfg after a test cd's. The SDK now reports paths relative to the absolute HOME, which surfaces in user-visible output as [TEST_TMP_DIR]/home/.databrickscfg (or [HOME]/.zshrc where the test registers a HOME replacement). The four committed outputs predated the fix and still expected the relative ./home form; regenerated with ./task test-update. Co-authored-by: Isaac
The previous fix resolved $home with `cd && pwd` to give HOME and USERPROFILE an absolute path. On Git Bash (MSYS), plain `pwd` returns Unix-style /c/... paths that the native Windows Go binary can't open, so the SDK silently fails to load ~/.databrickscfg and tests like cmd/api/default-profile (no auth resolves) and cmd/api/workspace-id-none (profile not read; SDK back-fills WorkspaceID from host metadata) fail on Windows only. Use `pwd -W` for USERPROFILE on MSYS/Cygwin to emit the mixed C:/... form Windows file APIs accept. HOME keeps the Unix-style path bash itself wants. Co-authored-by: Isaac
The absolute-path resolution (cd && pwd) introduced in 81d9297 works on macOS/Linux but emits Unix-style /c/... paths on Git Bash, which the native Windows Go binary can't open; the follow-up adb452f fixed the CLI path with `pwd -W` but broke tests like cmd/completion that compare the bash $HOME placeholder against the CLI's USERPROFILE-derived output. Revert sethome to the original simple form and restore the four outputs regenerated in f893006 to their pre-fix relative-./home forms. bundle_default_profile keeps its sub-cases but the cd'ing variants short-circuit on a missing cfg again (same expected output as before 81d9297). A separate PR will revisit the test setup to make absolute HOME work cleanly across platforms. Co-authored-by: Isaac
sethome exported HOME (and USERPROFILE) as the relative path the caller passed in (typically "./home"). The SDK expands `~/.databrickscfg` against $HOME at lookup time, so the moment a test cd's into a child directory the cfg "disappears": helpers like databrickscfg.GetConfiguredDefaultProfile silently return "" because the relative path no longer points at a real file. That made it easy to write tests that look like they exercise default_profile resolution but actually only succeed because the cfg lookup short-circuits. Resolve $1 to an absolute path with `cd && pwd` before exporting. On Git Bash (MSYS) plain `pwd` returns Unix-style /c/... paths that the native Windows Go binary can't open, so use `pwd -W` to get the mixed C:/... form. Use the same form for both HOME and USERPROFILE so tests like cmd/completion (which registers `$HOME` as the `[HOME]` replacement) match the CLI's USERPROFILE-derived output on Windows. Regenerate the four affected outputs. Co-authored-by: Isaac
8cbe33c to
b34db38
Compare
pietern
approved these changes
May 19, 2026
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.
Follow-up to #5214
sethome exported HOME (and USERPROFILE) as the relative path the caller passed in (typically "./home"). The SDK expands
~/.databrickscfgagainst $HOME at lookup time, so the moment a test cd's into a child directory the cfg "disappears": helpers likedatabrickscfg.GetConfiguredDefaultProfile silently return "" because the relative path no longer points at a real file. That made it easy to write tests that look like they exercise default_profile resolution but actually only succeed because the cfg lookup short-circuits.
Resolve $1 to an absolute path with
cd && pwdbefore exporting. On Git Bash (MSYS) plainpwdreturns Unix-style /c/... paths that the native Windows Go binary can't open, so usepwd -Wto get the mixed C:/... form. Use the same form for both HOME and USERPROFILE so tests like cmd/completion (which registers$HOMEas the[HOME]replacement) match the CLI's USERPROFILE-derived output on Windows.Regenerate the four affected outputs.
Co-authored-by: Isaac