Skip to content

Commit

Permalink
Windows uses USERPROFILE not HOME
Browse files Browse the repository at this point in the history
When dealing with environment variables that set $HOME, we do not get
the desired result.  Windows will honor USERPROFILE.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <[email protected]>
  • Loading branch information
baude committed Feb 13, 2024
1 parent c88c689 commit 001824b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/machine/e2e/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ func setup() (string, *machineTestBuilder) {
if err := os.Setenv("HOME", homeDir); err != nil {
Fail("failed to set home dir")
}
if runtime.GOOS == "windows" {
if err := os.Setenv("USERPROFILE", homeDir); err != nil {
Fail("unable to set home dir on windows")
}
}
if err := os.Setenv("XDG_RUNTIME_DIR", homeDir); err != nil {
Fail("failed to set xdg_runtime dir")
}
Expand Down Expand Up @@ -203,4 +208,9 @@ func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) {
if err := os.Setenv("HOME", origHomeDir); err != nil {
Fail("failed to set home dir")
}
if runtime.GOOS == "windows" {
if err := os.Setenv("USERPROFILE", origHomeDir); err != nil {
Fail("failed to set windows home dir back to original")
}
}
}

0 comments on commit 001824b

Please sign in to comment.