]> Cypherpunks repositories - gostls13.git/commitdiff
internal/fuzz: disconnect stdout and stderr from the worker
authorKatie Hockman <katie@golang.org>
Tue, 28 Sep 2021 19:59:34 +0000 (15:59 -0400)
committerKatie Hockman <katie@golang.org>
Wed, 29 Sep 2021 19:53:09 +0000 (19:53 +0000)
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>

src/cmd/go/internal/test/test.go
src/internal/fuzz/worker.go

index a6c8631a3751d7754b502bf8a2e7d639334ff81d..dc1bea505bda24ebd09183d9ae0fa879aecaf4e9 100644 (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
index 5b24e575c039d96fffa1d2bd700b8ff95cd76d0a..1429decba83929a4aaecd068a19bc6e32637669a 100644 (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