Sfoglia il codice sorgente

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 anni fa
parent
commit
bc9641e20d
1 ha cambiato i file con 8 aggiunte e 0 eliminazioni
  1. 8
    0
      internal/driver/fetch_test.go

+ 8
- 0
internal/driver/fetch_test.go Vedi File

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