Explorar el Código

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 hace 7 años
padre
commit
bc9641e20d
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8
    0
      internal/driver/fetch_test.go

+ 8
- 0
internal/driver/fetch_test.go Ver fichero

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