浏览代码

internal/driver: use homeEnv function in tests

In changeset f90721db3d, fetch.go was changed to handle
the correct home directory environment variable on Plan 9
and Windows, but the tests were still using the $HOME
environment variable.

We change the tests to use the homeEnv function instead
of the $HOME environment variable.

Fixes #100.
David du Colombier 8 年前
父节点
当前提交
117d3eccd9
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3
    3
      internal/driver/fetch_test.go

+ 3
- 3
internal/driver/fetch_test.go 查看文件

38
 	}
38
 	}
39
 
39
 
40
 	// Save environment variables to restore after test
40
 	// Save environment variables to restore after test
41
-	saveHome := os.Getenv("HOME")
41
+	saveHome := os.Getenv(homeEnv())
42
 	savePath := os.Getenv("PPROF_BINARY_PATH")
42
 	savePath := os.Getenv("PPROF_BINARY_PATH")
43
 
43
 
44
 	tempdir, err := ioutil.TempDir("", "home")
44
 	tempdir, err := ioutil.TempDir("", "home")
50
 	os.Create(filepath.Join(tempdir, "pprof", "binaries", "abcde10001", "binary"))
50
 	os.Create(filepath.Join(tempdir, "pprof", "binaries", "abcde10001", "binary"))
51
 
51
 
52
 	obj := testObj{tempdir}
52
 	obj := testObj{tempdir}
53
-	os.Setenv("HOME", tempdir)
53
+	os.Setenv(homeEnv(), tempdir)
54
 	for _, tc := range []struct {
54
 	for _, tc := range []struct {
55
 		env, file, buildID, want string
55
 		env, file, buildID, want string
56
 		msgCount                 int
56
 		msgCount                 int
79
 			t.Errorf("%s:%s:%s, want %s, got %s", tc.env, tc.file, tc.buildID, tc.want, file)
79
 			t.Errorf("%s:%s:%s, want %s, got %s", tc.env, tc.file, tc.buildID, tc.want, file)
80
 		}
80
 		}
81
 	}
81
 	}
82
-	os.Setenv("HOME", saveHome)
82
+	os.Setenv(homeEnv(), saveHome)
83
 	os.Setenv("PPROF_BINARY_PATH", savePath)
83
 	os.Setenv("PPROF_BINARY_PATH", savePath)
84
 }
84
 }
85
 
85