From 4cb926001cbc068dac62012d86ed1dfbd0a66690 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 29 Oct 2019 09:27:57 -0700 Subject: cmd/compile/internal/syntax: silence test function output Don't print to stdout in non-verbose (-v) test mode. Exception: Timing output (2 lines) of TestStdLib. If we want to disable that as well we should use another flag to differenciate between -verbose output and measurement results. Leaving alone for now. Fixes #35223. Change-Id: Ie8160760e8db1138f9031888d654eaeab202128c Reviewed-on: https://go-review.googlesource.com/c/go/+/204039 Reviewed-by: Brad Fitzpatrick --- src/cmd/compile/internal/syntax/printer_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/cmd/compile/internal/syntax/printer_test.go') diff --git a/src/cmd/compile/internal/syntax/printer_test.go b/src/cmd/compile/internal/syntax/printer_test.go index bc78f01265..c3b9aca229 100644 --- a/src/cmd/compile/internal/syntax/printer_test.go +++ b/src/cmd/compile/internal/syntax/printer_test.go @@ -6,6 +6,8 @@ package syntax import ( "fmt" + "io" + "io/ioutil" "os" "strings" "testing" @@ -23,7 +25,7 @@ func TestPrint(t *testing.T) { } if ast != nil { - Fprint(os.Stdout, ast, true) + Fprint(testOut(), ast, true) fmt.Println() } } @@ -44,3 +46,10 @@ func TestPrintString(t *testing.T) { } } } + +func testOut() io.Writer { + if testing.Verbose() { + return os.Stdout + } + return ioutil.Discard +} -- cgit v1.2.3-54-g00ecf