]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: forward stderr if 'go env CGO_ENABLED' fails
authorBryan C. Mills <bcmills@google.com>
Fri, 6 Mar 2020 19:32:26 +0000 (14:32 -0500)
committerBryan C. Mills <bcmills@google.com>
Fri, 6 Mar 2020 20:06:47 +0000 (20:06 +0000)
The default error string for a command failure is just its status code,
and "exit status 1" is not at all helpful for debugging.

Change-Id: I822c89bcc9e73283b33e01792bf9c40b1add3c35
Reviewed-on: https://go-review.googlesource.com/c/go/+/222308
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
src/cmd/dist/test.go

index 48c36a63fcbe3a661537b74c11b2754de1b6d2d2..43d8089c65bde9ee18a0cb04041bf07d4cd6fb71 100644 (file)
@@ -98,9 +98,11 @@ func (t *tester) run() {
                os.Setenv("PATH", fmt.Sprintf("%s%c%s", gobin, os.PathListSeparator, os.Getenv("PATH")))
        }
 
-       slurp, err := exec.Command("go", "env", "CGO_ENABLED").Output()
+       cmd := exec.Command("go", "env", "CGO_ENABLED")
+       cmd.Stderr = new(bytes.Buffer)
+       slurp, err := cmd.Output()
        if err != nil {
-               fatalf("Error running go env CGO_ENABLED: %v", err)
+               fatalf("Error running go env CGO_ENABLED: %v\n%s", err, cmd.Stderr)
        }
        t.cgoEnabled, _ = strconv.ParseBool(strings.TrimSpace(string(slurp)))
        if flag.NArg() > 0 && t.runRxStr != "" {