1
0
mirror of https://github.com/golang/go synced 2024-11-17 04:04:46 -07:00

internal/fuzz: disconnect stdout and stderr from the worker

This was useful for debugging while we were developing
the feature, but is now causing extraneous prints that
make the command output difficult to read.

This change also prevents the go command from printing
an extraneous "FAIL" when fuzzing is enabled.

Fixes #48633
Fixes #46631

Change-Id: I636e65f305a20f6dcd843e62090ae228741a3725
Reviewed-on: https://go-review.googlesource.com/c/go/+/352892
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Katie Hockman 2021-09-28 15:59:34 -04:00
parent 82ac9ab83a
commit e213c72fb9
2 changed files with 16 additions and 4 deletions

View File

@ -1790,9 +1790,23 @@ func builderNoTest(b *work.Builder, ctx context.Context, a *work.Action) error {
return nil
}
// printExitStatus is the action for printing the exit status
// printExitStatus is the action for printing the final exit status.
// If we are running multiple test targets, print a final "FAIL"
// in case a failure in an early package has already scrolled
// off of the user's terminal.
// (See https://golang.org/issue/30507#issuecomment-470593235.)
//
// In JSON mode, we need to maintain valid JSON output and
// we assume that the test output is being parsed by a tool
// anyway, so the failure will not be missed and would be
// awkward to try to wedge into the JSON stream.
//
// In fuzz mode, we only allow a single package for now
// (see CL 350156 and https://golang.org/issue/46312),
// so there is no possibility of scrolling off and no need
// to print the final status.
func printExitStatus(b *work.Builder, ctx context.Context, a *work.Action) error {
if !testJSON && len(pkgArgs) != 0 {
if !testJSON && testFuzz == "" && len(pkgArgs) != 0 {
if base.GetExitStatus() != 0 {
fmt.Println("FAIL")
return nil

View File

@ -331,8 +331,6 @@ func (w *worker) start() (err error) {
cmd := exec.Command(w.binPath, w.args...)
cmd.Dir = w.dir
cmd.Env = w.env[:len(w.env):len(w.env)] // copy on append to ensure workers don't overwrite each other.
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
// Create the "fuzz_in" and "fuzz_out" pipes so we can communicate with
// the worker. We don't use stdin and stdout, since the test binary may