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>
package syntax
import (
- "os"
"testing"
)
}
if ast != nil {
- Fdump(os.Stdout, ast)
+ Fdump(testOut(), ast)
}
}
import (
"fmt"
+ "io"
+ "io/ioutil"
"os"
"strings"
"testing"
}
if ast != nil {
- Fprint(os.Stdout, ast, true)
+ Fprint(testOut(), ast, true)
fmt.Println()
}
}
}
}
}
+
+func testOut() io.Writer {
+ if testing.Verbose() {
+ return os.Stdout
+ }
+ return ioutil.Discard
+}
if s.tok == _EOF {
break
}
+ if !testing.Verbose() {
+ continue
+ }
switch s.tok {
case _Name:
fmt.Println(s.line, s.tok, "=>", s.lit)