aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKatie Hockman <katie@golang.org>2021-09-28 15:59:34 -0400
committerKatie Hockman <katie@golang.org>2021-09-29 19:53:09 +0000
commite213c72fb9492a409bd0ed9620ca9aaaa96ddebe (patch)
treea00e94c5b71e58adb157dfa9a44c684bab7d013f /src
parent82ac9ab83a47468046bda9bf6c4676a9695fae24 (diff)
downloadgo-e213c72fb9492a409bd0ed9620ca9aaaa96ddebe.tar.xz
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>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/internal/test/test.go18
-rw-r--r--src/internal/fuzz/worker.go2
2 files changed, 16 insertions, 4 deletions
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index a6c8631a37..dc1bea505b 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -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
diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go
index 5b24e575c0..1429decba8 100644
--- a/src/internal/fuzz/worker.go
+++ b/src/internal/fuzz/worker.go
@@ -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