pull/8520/merge
Maisem Ali 2023-07-08 20:13:27 -07:00 committed by GitHub
commit be1441692b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -81,6 +81,7 @@ func runTests(ctx context.Context, attempt int, pt *packageTests, otherArgs []st
if err != nil {
log.Printf("error creating stdout pipe: %v", err)
}
defer r.Close()
cmd.Stderr = os.Stderr
cmd.Env = os.Environ()
@ -104,6 +105,15 @@ func runTests(ctx context.Context, attempt int, pt *packageTests, otherArgs []st
if errors.Is(err, io.EOF) || errors.Is(err, os.ErrClosed) {
break
}
// `go test -json` outputs invalid JSON when a build fails.
// In that case, discard the the output and start reading again.
// The build error will be printed to stderr.
// See: https://github.com/golang/go/issues/35169
if _, ok := err.(*json.SyntaxError); ok {
jd = json.NewDecoder(r)
continue
}
panic(err)
}
if goOutput.Test == "" {