소스 검색

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()