cmd/cgo/internal/testshared: log stdout when go command fails

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>
This commit is contained in:
qmuntal 2025-03-20 09:41:28 +01:00 committed by Quim Muntal
parent 665af86992
commit a4a5ef08bd

View 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 {