Text file src/cmd/go/testdata/script/test_regexps.txt

     1  go test -cpu=1 -run=X/Y -bench=X/Y -count=2 -v testregexp
     2  
     3  # Test the following:
     4  
     5  # TestX is run, twice
     6  stdout -count=2 '^=== RUN   TestX$'
     7  stdout -count=2 '^    x_test.go:6: LOG: X running$'
     8  
     9  # TestX/Y is run, twice
    10  stdout -count=2 '^=== RUN   TestX/Y$'
    11  stdout -count=2 '^    x_test.go:8: LOG: Y running$'
    12  
    13  # TestXX is run, twice
    14  stdout -count=2 '^=== RUN   TestXX$'
    15  stdout -count=2 '^    z_test.go:10: LOG: XX running'
    16  
    17  # TestZ is not run
    18  ! stdout '^=== RUN   TestZ$'
    19  
    20  # BenchmarkX is run with N=1 once, only to discover what sub-benchmarks it has,
    21  # and should not print a final summary line.
    22  stdout -count=1 '^    x_test.go:13: LOG: X running N=1$'
    23  ! stdout '^\s+BenchmarkX: x_test.go:13: LOG: X running N=\d\d+'
    24  ! stdout 'BenchmarkX\s+\d+'
    25  
    26  # Same for BenchmarkXX.
    27  stdout -count=1 '^    z_test.go:18: LOG: XX running N=1$'
    28  ! stdout  '^    z_test.go:18: LOG: XX running N=\d\d+'
    29  ! stdout 'BenchmarkXX\s+\d+'
    30  
    31  # BenchmarkX/Y is run in full twice due to -count=2.
    32  # "Run in full" means that it runs for approximately the default benchtime,
    33  # but may cap out at N=1e9.
    34  # We don't actually care what the final iteration count is, but it should be
    35  # a large number, and the last iteration count prints right before the results.
    36  stdout -count=2 '^    x_test.go:15: LOG: Y running N=[1-9]\d{4,}\nBenchmarkX/Y\s+\d+'
    37  
    38  -- go.mod --
    39  module testregexp
    40  
    41  go 1.16
    42  -- x_test.go --
    43  package x
    44  
    45  import "testing"
    46  
    47  func TestX(t *testing.T) {
    48  	t.Logf("LOG: X running")
    49  	t.Run("Y", func(t *testing.T) {
    50  		t.Logf("LOG: Y running")
    51  	})
    52  }
    53  
    54  func BenchmarkX(b *testing.B) {
    55  	b.Logf("LOG: X running N=%d", b.N)
    56  	b.Run("Y", func(b *testing.B) {
    57  		b.Logf("LOG: Y running N=%d", b.N)
    58  	})
    59  }
    60  -- z_test.go --
    61  package x
    62  
    63  import "testing"
    64  
    65  func TestZ(t *testing.T) {
    66  	t.Logf("LOG: Z running")
    67  }
    68  
    69  func TestXX(t *testing.T) {
    70  	t.Logf("LOG: XX running")
    71  }
    72  
    73  func BenchmarkZ(b *testing.B) {
    74  	b.Logf("LOG: Z running N=%d", b.N)
    75  }
    76  
    77  func BenchmarkXX(b *testing.B) {
    78  	b.Logf("LOG: XX running N=%d", b.N)
    79  }
    80  

View as plain text