Skip to content

Commit b8a5b8d

Browse files
committed
tests: set USERPROFILE alongside HOME so Windows test job picks up the right tempdir
Moving aitools to top-level cmd/ and libs/ means TEST_PACKAGES on Windows now runs these tests via ./cmd/... and ./libs/... globs; previously they lived under experimental/aitools/, which Windows skipped. The tests set HOME, but env.HomeEnvVar() returns "USERPROFILE" on Windows. Set both env vars at every call site, following the libs/git pattern. Co-authored-by: Isaac
1 parent dbc227b commit b8a5b8d

5 files changed

Lines changed: 18 additions & 1 deletion

File tree

cmd/aitools/install_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func setupTestAgents(t *testing.T) string {
5353
t.Helper()
5454
tmp := t.TempDir()
5555
t.Setenv("HOME", tmp)
56+
t.Setenv("USERPROFILE", tmp)
5657
// Create config dirs for two agents.
5758
require.NoError(t, os.MkdirAll(filepath.Join(tmp, ".claude"), 0o755))
5859
require.NoError(t, os.MkdirAll(filepath.Join(tmp, ".cursor"), 0o755))
@@ -224,6 +225,7 @@ func TestInstallNonInteractiveUsesAllAgents(t *testing.T) {
224225
func TestInstallNoAgentsDetected(t *testing.T) {
225226
tmp := t.TempDir()
226227
t.Setenv("HOME", tmp)
228+
t.Setenv("USERPROFILE", tmp)
227229

228230
calls := setupInstallMock(t)
229231
ctx := cmdio.MockDiscard(t.Context())

cmd/aitools/version_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
func TestVersionShowsBothScopes(t *testing.T) {
1616
tmp := t.TempDir()
1717
t.Setenv("HOME", tmp)
18+
t.Setenv("USERPROFILE", tmp)
1819
t.Setenv("DATABRICKS_SKILLS_REF", "v0.1.0")
1920

2021
// Create global state.
@@ -70,6 +71,7 @@ func TestVersionShowsBothScopes(t *testing.T) {
7071
func TestVersionShowsSingleScopeWithoutQualifier(t *testing.T) {
7172
tmp := t.TempDir()
7273
t.Setenv("HOME", tmp)
74+
t.Setenv("USERPROFILE", tmp)
7375
t.Setenv("DATABRICKS_SKILLS_REF", "v0.1.0")
7476

7577
// Create only global state.

libs/aitools/agents/recommend_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func noopInstall(context.Context) error { return nil }
1717
func TestRecommendSkillsInstallSkipsWhenSkillsExist(t *testing.T) {
1818
tmpDir := t.TempDir()
1919
t.Setenv("HOME", tmpDir)
20+
t.Setenv("USERPROFILE", tmpDir)
2021
// Skills must be in canonical location to be detected.
2122
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir, CanonicalSkillsDir, "databricks"), 0o755))
2223

@@ -39,7 +40,9 @@ func TestRecommendSkillsInstallSkipsWhenSkillsExist(t *testing.T) {
3940
}
4041

4142
func TestRecommendSkillsInstallSkipsWhenNoAgents(t *testing.T) {
42-
t.Setenv("HOME", t.TempDir())
43+
tmp := t.TempDir()
44+
t.Setenv("HOME", tmp)
45+
t.Setenv("USERPROFILE", tmp)
4346

4447
origRegistry := Registry
4548
Registry = []Agent{}
@@ -53,6 +56,7 @@ func TestRecommendSkillsInstallSkipsWhenNoAgents(t *testing.T) {
5356
func TestRecommendSkillsInstallNonInteractive(t *testing.T) {
5457
tmpDir := t.TempDir()
5558
t.Setenv("HOME", tmpDir)
59+
t.Setenv("USERPROFILE", tmpDir)
5660

5761
origRegistry := Registry
5862
Registry = []Agent{
@@ -73,6 +77,7 @@ func TestRecommendSkillsInstallNonInteractive(t *testing.T) {
7377
func TestRecommendSkillsInstallInteractiveDecline(t *testing.T) {
7478
tmpDir := t.TempDir()
7579
t.Setenv("HOME", tmpDir)
80+
t.Setenv("USERPROFILE", tmpDir)
7681

7782
origRegistry := Registry
7883
Registry = []Agent{

libs/aitools/agents/skills_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestHasDatabricksSkillsInstalledNoAgents(t *testing.T) {
2121
func TestHasDatabricksSkillsInstalledCanonicalOnly(t *testing.T) {
2222
tmpHome := t.TempDir()
2323
t.Setenv("HOME", tmpHome)
24+
t.Setenv("USERPROFILE", tmpHome)
2425
require.NoError(t, os.MkdirAll(filepath.Join(tmpHome, CanonicalSkillsDir, "databricks"), 0o755))
2526

2627
origRegistry := Registry
@@ -39,6 +40,7 @@ func TestHasDatabricksSkillsInstalledCanonicalOnly(t *testing.T) {
3940
func TestHasDatabricksSkillsInstalledIgnoresAgentDir(t *testing.T) {
4041
tmpHome := t.TempDir()
4142
t.Setenv("HOME", tmpHome)
43+
t.Setenv("USERPROFILE", tmpHome)
4244
// Skills in agent dir only (e.g., installed by another tool) should not count.
4345
agentDir := filepath.Join(tmpHome, ".claude")
4446
require.NoError(t, os.MkdirAll(filepath.Join(agentDir, "skills", "databricks"), 0o755))
@@ -59,6 +61,7 @@ func TestHasDatabricksSkillsInstalledIgnoresAgentDir(t *testing.T) {
5961
func TestHasDatabricksSkillsInstalledWithOnlyNonDatabricksSkills(t *testing.T) {
6062
tmpDir := t.TempDir()
6163
t.Setenv("HOME", tmpDir)
64+
t.Setenv("USERPROFILE", tmpDir)
6265
// Non-databricks skills should not count.
6366
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir, "skills", "mcp-builder"), 0o755))
6467
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir, "skills", "rust-webapp"), 0o755))
@@ -79,6 +82,7 @@ func TestHasDatabricksSkillsInstalledWithOnlyNonDatabricksSkills(t *testing.T) {
7982
func TestHasDatabricksSkillsInstalledNoSkillsDir(t *testing.T) {
8083
tmpDir := t.TempDir()
8184
t.Setenv("HOME", tmpDir)
85+
t.Setenv("USERPROFILE", tmpDir)
8286

8387
origRegistry := Registry
8488
Registry = []Agent{
@@ -96,6 +100,7 @@ func TestHasDatabricksSkillsInstalledNoSkillsDir(t *testing.T) {
96100
func TestHasDatabricksSkillsInstalledCustomSubdirNotChecked(t *testing.T) {
97101
tmpHome := t.TempDir()
98102
t.Setenv("HOME", tmpHome)
103+
t.Setenv("USERPROFILE", tmpHome)
99104
// Skills in agent's custom subdir should not count — only canonical matters.
100105
require.NoError(t, os.MkdirAll(filepath.Join(tmpHome, ".gemini", "antigravity", "global_skills", "databricks"), 0o755))
101106

@@ -116,6 +121,7 @@ func TestHasDatabricksSkillsInstalledCustomSubdirNotChecked(t *testing.T) {
116121
func TestHasDatabricksSkillsInstalledDatabricksAppsCanonical(t *testing.T) {
117122
tmpHome := t.TempDir()
118123
t.Setenv("HOME", tmpHome)
124+
t.Setenv("USERPROFILE", tmpHome)
119125
// databricks-apps prefix should match in canonical location.
120126
require.NoError(t, os.MkdirAll(filepath.Join(tmpHome, CanonicalSkillsDir, "databricks-apps"), 0o755))
121127

@@ -138,6 +144,7 @@ func TestHasDatabricksSkillsInstalledDatabricksAppsCanonical(t *testing.T) {
138144
func TestHasDatabricksSkillsInstalledLegacyPath(t *testing.T) {
139145
tmpHome := t.TempDir()
140146
t.Setenv("HOME", tmpHome)
147+
t.Setenv("USERPROFILE", tmpHome)
141148
// Skills only in the legacy location should still be detected.
142149
require.NoError(t, os.MkdirAll(filepath.Join(tmpHome, legacySkillsDir, "databricks"), 0o755))
143150

libs/aitools/installer/installer_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func setupTestHome(t *testing.T) string {
7272
t.Helper()
7373
tmp := t.TempDir()
7474
t.Setenv("HOME", tmp)
75+
t.Setenv("USERPROFILE", tmp)
7576
// Create agent config dir so the agent is "detected".
7677
require.NoError(t, os.MkdirAll(filepath.Join(tmp, ".test-agent"), 0o755))
7778
return tmp

0 commit comments

Comments
 (0)