Skip to content

Commit 2a0818f

Browse files
committed
test(config): set USERPROFILE in folder_cache test setup for Windows
os.UserHomeDir() reads HOME on Linux/macOS but USERPROFILE on Windows. The existing t.Setenv("HOME", ...) had no effect on windows-latest, so every test resolved cacheDir() to the runner's real %USERPROFILE%, where state leaked across tests in the package and produced the failures seen on PR #1007's windows-latest job.
1 parent 98af8cb commit 2a0818f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

config/folder_cache_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import (
1010

1111
// folderCacheTestSetup redirects HOME to a per-test temp directory so
1212
// cacheDir() resolves under the temp tree and the cache file does not
13-
// collide with the user's real ~/.cache/matcha state.
13+
// collide with the user's real ~/.cache/matcha state. USERPROFILE is set
14+
// for the same reason on Windows, where os.UserHomeDir() reads it instead
15+
// of HOME.
1416
func folderCacheTestSetup(t *testing.T) string {
1517
t.Helper()
1618
tempDir := t.TempDir()
1719
t.Setenv("HOME", tempDir)
20+
t.Setenv("USERPROFILE", tempDir)
1821
return tempDir
1922
}
2023

0 commit comments

Comments
 (0)