Skip to content

Commit 9febc8c

Browse files
Fix e2e tests on Windows: set USERPROFILE alongside HOME
os.UserHomeDir() reads USERPROFILE on Windows, not HOME. E2E tests only set HOME, so the CLI looked at the real home directory instead of the test fixture. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0192twUPgNxmFCpvpsBk5uqg
1 parent 90994e5 commit 9febc8c

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎cmd/cc-session/e2e_test.go‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ func binaryName() string {
1717
return "cc-session"
1818
}
1919

20+
func homeEnv(root string) []string {
21+
env := os.Environ()
22+
env = append(env, "HOME="+root)
23+
if runtime.GOOS == "windows" {
24+
env = append(env, "USERPROFILE="+root)
25+
}
26+
return env
27+
}
28+
2029
func TestCLI_WhenSessionExists_ThenListReadContextAndAuditWorkEndToEnd(t *testing.T) {
2130
root := t.TempDir()
2231
bin := filepath.Join(root, binaryName())
@@ -97,7 +106,7 @@ func TestCLI_WhenSessionExists_ThenListReadContextAndAuditWorkEndToEnd(t *testin
97106
for _, tt := range tests {
98107
t.Run(tt.name, func(t *testing.T) {
99108
cmd := exec.Command(bin, tt.args...)
100-
cmd.Env = append(os.Environ(), "HOME="+root)
109+
cmd.Env = homeEnv(root)
101110
out, err := cmd.CombinedOutput()
102111
if err != nil {
103112
t.Fatalf("%s failed: %v\n%s", strings.Join(tt.args, " "), err, out)
@@ -141,7 +150,7 @@ func TestCLI_WhenSubcommandFails_ThenPrintsErrorPrefixAndExitsNonZero(t *testing
141150
for _, tt := range tests {
142151
t.Run(tt.name, func(t *testing.T) {
143152
cmd := exec.Command(bin, tt.args...)
144-
cmd.Env = append(os.Environ(), "HOME="+root)
153+
cmd.Env = homeEnv(root)
145154
out, err := cmd.CombinedOutput()
146155

147156
var exitErr *exec.ExitError

0 commit comments

Comments
 (0)