]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/syntax: silence test function output
authorRobert Griesemer <gri@golang.org>
Tue, 29 Oct 2019 16:27:57 +0000 (09:27 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 6 Nov 2019 17:02:19 +0000 (17:02 +0000)
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>
src/cmd/compile/internal/syntax/dumper_test.go
src/cmd/compile/internal/syntax/printer_test.go
src/cmd/compile/internal/syntax/scanner_test.go

index 32337eb6f143de6fdf4e241d3ee0de8e8448b74d..f84bd2d7056f03f6456017fed65a65793cc809ad 100644 (file)
@@ -5,7 +5,6 @@
 package syntax
 
 import (
-       "os"
        "testing"
 )
 
@@ -21,6 +20,6 @@ func TestDump(t *testing.T) {
        }
 
        if ast != nil {
-               Fdump(os.Stdout, ast)
+               Fdump(testOut(), ast)
        }
 }
index bc78f0126583364f1aa596aa293bb4dd8fd79fba..c3b9aca229c3358a69ef17b7b72b3fbf8458fb87 100644 (file)
@@ -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
+}
index 717deb9073f30605df4660a2dba81e5424098f91..d76231a4af541e74d9c4a19555f881e252d7193a 100644 (file)
@@ -30,6 +30,9 @@ func TestScanner(t *testing.T) {
                if s.tok == _EOF {
                        break
                }
+               if !testing.Verbose() {
+                       continue
+               }
                switch s.tok {
                case _Name:
                        fmt.Println(s.line, s.tok, "=>", s.lit)