Skip to content

Commit 9c5887b

Browse files
thepuddspull[bot]
authored andcommitted
cmd/internal/testdir: print stderr if go list fails while gathering stdlib import config
If cmd/compile is in an unhappy state, the testdir test can fail with an unhelpful 'exit code 1' log message if 'go list' fails while gathering stdlib import config When running individual files, such as: go test cmd/internal/testdir -run='Test/escape.*.go' This might also happen in other uses, or it might be that a more expansive set of tests such as run.bash might first trigger a more useful error. This change prints stderr and states that it is 'go list' that is having problems to help someone track down the proper issue. Change-Id: Iba658ea139bb9087ab8adb00c9f65080a1b6ee76 Reviewed-on: https://go-review.googlesource.com/c/go/+/524941 Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Russ Cox <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent a79d6ec commit 9c5887b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cmd/internal/testdir/testdir_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ var stdlibImportcfg = sync.OnceValue(func() string {
215215
cmd := exec.Command(goTool, "list", "-export", "-f", "{{if .Export}}packagefile {{.ImportPath}}={{.Export}}{{end}}", "std")
216216
cmd.Env = append(os.Environ(), "GOENV=off", "GOFLAGS=")
217217
output, err := cmd.Output()
218+
if err, ok := err.(*exec.ExitError); ok && len(err.Stderr) != 0 {
219+
log.Fatalf("'go list' failed: %v: %s", err, err.Stderr)
220+
}
218221
if err != nil {
219-
log.Fatal(err)
222+
log.Fatalf("'go list' failed: %v", err)
220223
}
221224
return string(output)
222225
})

0 commit comments

Comments
 (0)