aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/printer_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2019-10-29 09:27:57 -0700
committerRobert Griesemer <gri@golang.org>2019-11-06 17:02:19 +0000
commit4cb926001cbc068dac62012d86ed1dfbd0a66690 (patch)
tree801658d1de16c1ea23178f2c88f35d371e675027 /src/cmd/compile/internal/syntax/printer_test.go
parenta5936a489462a2f68ee2ae1a53dd48c0458029a7 (diff)
downloadgo-4cb926001cbc068dac62012d86ed1dfbd0a66690.tar.gz
go-4cb926001cbc068dac62012d86ed1dfbd0a66690.zip
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 <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/syntax/printer_test.go')
-rw-r--r--src/cmd/compile/internal/syntax/printer_test.go11
1 files changed, 10 insertions, 1 deletions
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
+}