]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/logopt: preserve env while running command
authorEgon Elbre <egonelbre@gmail.com>
Tue, 7 Apr 2020 12:52:05 +0000 (15:52 +0300)
committerDavid Chase <drchase@google.com>
Tue, 7 Apr 2020 17:18:30 +0000 (17:18 +0000)
The test was not preserving temporary directory flags leading to a
failure on windows with:

    mkdir C:\WINDOWS\go-build315158903: Access is denied.

Fixes #38251

Change-Id: I6ee31b31e84b7f6e75ea6ee0f3b8c094835bf5d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/227497
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/logopt/logopt_test.go

index 040d8cee0b5ecee62b9630eb53a8dc1946b8ca9d..cc28536fd4a3ec2f77296e85d7e5d2b894020caf 100644 (file)
@@ -199,7 +199,7 @@ func testCopy(t *testing.T, dir, goarch, goos, src, outfile string) (string, err
        t.Log(run)
        cmd := exec.Command(run[0], run[1:]...)
        cmd.Dir = dir
-       cmd.Env = []string{"GOARCH=" + goarch, "GOOS=" + goos}
+       cmd.Env = append(os.Environ(), "GOARCH="+goarch, "GOOS="+goos)
        out, err := cmd.CombinedOutput()
        t.Logf("%s", out)
        return string(out), err