瀏覽代碼

Set HOME to a temporary directory in TestHttpsInsecure (#305)

Debian builds packages with HOME set to a bogus value and this causes tests to
fail when packaging Go 1.10...
Michael Hudson-Doyle 7 年之前
父節點
當前提交
bc9641e20d
共有 1 個檔案被更改,包括 8 行新增0 行删除
  1. 8
    0
      internal/driver/fetch_test.go

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

@@ -362,6 +362,14 @@ func TestHttpsInsecure(t *testing.T) {
362 362
 	if runtime.GOOS == "nacl" {
363 363
 		t.Skip("test assumes tcp available")
364 364
 	}
365
+	saveHome := os.Getenv(homeEnv())
366
+	tempdir, err := ioutil.TempDir("", "home")
367
+	if err != nil {
368
+		t.Fatal("creating temp dir: ", err)
369
+	}
370
+	defer os.RemoveAll(tempdir)
371
+	os.Setenv(homeEnv(), tempdir)
372
+	defer os.Setenv(homeEnv(), saveHome)
365 373
 
366 374
 	baseVars := pprofVariables
367 375
 	pprofVariables = baseVars.makeCopy()