]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo/internal/testshared: log stdout when go command fails
authorqmuntal <quimmuntal@gmail.com>
Thu, 20 Mar 2025 08:41:28 +0000 (09:41 +0100)
committerQuim Muntal <quimmuntal@gmail.com>
Thu, 20 Mar 2025 16:09:46 +0000 (09:09 -0700)
Understanding a failure in the goCmd call is difficult because the
important information might be in the stdout instead of stderr.

Change-Id: Icf42974679103c69016129fe2ebb15d5a0a3b51a
Reviewed-on: https://go-review.googlesource.com/c/go/+/659456
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/cmd/cgo/internal/testshared/shared_test.go

index 814b9994f824abaa76c25dab477e15f0cedd6504..a2214ac5b96d1a815299defc88489370ea3d598c 100644 (file)
@@ -79,10 +79,10 @@ func goCmd(t *testing.T, args ...string) string {
        if err != nil {
                if t != nil {
                        t.Helper()
-                       t.Fatalf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, stderr)
+                       t.Fatalf("executing %q failed %v:\n%s\n%s", c, err, stderr, output)
                } else {
                        // Panic instead of using log.Fatalf so that deferred cleanup may run in testMain.
-                       log.Panicf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, stderr)
+                       log.Panicf("executing %q failed %v:\n%s\n%s", c, err, stderr, output)
                }
        }
        if testing.Verbose() && t != nil {