Commit 4cb92600 authored by Robert Griesemer's avatar Robert Griesemer

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/+/204039Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent a5936a48
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package syntax package syntax
import ( import (
"os"
"testing" "testing"
) )
...@@ -21,6 +20,6 @@ func TestDump(t *testing.T) { ...@@ -21,6 +20,6 @@ func TestDump(t *testing.T) {
} }
if ast != nil { if ast != nil {
Fdump(os.Stdout, ast) Fdump(testOut(), ast)
} }
} }
...@@ -6,6 +6,8 @@ package syntax ...@@ -6,6 +6,8 @@ package syntax
import ( import (
"fmt" "fmt"
"io"
"io/ioutil"
"os" "os"
"strings" "strings"
"testing" "testing"
...@@ -23,7 +25,7 @@ func TestPrint(t *testing.T) { ...@@ -23,7 +25,7 @@ func TestPrint(t *testing.T) {
} }
if ast != nil { if ast != nil {
Fprint(os.Stdout, ast, true) Fprint(testOut(), ast, true)
fmt.Println() fmt.Println()
} }
} }
...@@ -44,3 +46,10 @@ func TestPrintString(t *testing.T) { ...@@ -44,3 +46,10 @@ func TestPrintString(t *testing.T) {
} }
} }
} }
func testOut() io.Writer {
if testing.Verbose() {
return os.Stdout
}
return ioutil.Discard
}
...@@ -30,6 +30,9 @@ func TestScanner(t *testing.T) { ...@@ -30,6 +30,9 @@ func TestScanner(t *testing.T) {
if s.tok == _EOF { if s.tok == _EOF {
break break
} }
if !testing.Verbose() {
continue
}
switch s.tok { switch s.tok {
case _Name: case _Name:
fmt.Println(s.line, s.tok, "=>", s.lit) fmt.Println(s.line, s.tok, "=>", s.lit)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment