...

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

Documentation: cmd/go/testdata/script

     1go test -cpu=1 -run=X/Y -bench=X/Y -count=2 -v testregexp
     2
     3# Test the following:
     4
     5# TestX is run, twice
     6stdout -count=2 '^=== RUN   TestX$'
     7stdout -count=2 '^    x_test.go:6: LOG: X running$'
     8
     9# TestX/Y is run, twice
    10stdout -count=2 '^=== RUN   TestX/Y$'
    11stdout -count=2 '^    x_test.go:8: LOG: Y running$'
    12
    13# TestXX is run, twice
    14stdout -count=2 '^=== RUN   TestXX$'
    15stdout -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.
    22stdout -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.
    27stdout -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.
    36stdout -count=2 '^    x_test.go:15: LOG: Y running N=[1-9]\d{4,}\nBenchmarkX/Y\s+\d+'
    37
    38-- go.mod --
    39module testregexp
    40
    41go 1.16
    42-- x_test.go --
    43package x
    44
    45import "testing"
    46
    47func 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
    54func 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 --
    61package x
    62
    63import "testing"
    64
    65func TestZ(t *testing.T) {
    66	t.Logf("LOG: Z running")
    67}
    68
    69func TestXX(t *testing.T) {
    70	t.Logf("LOG: XX running")
    71}
    72
    73func BenchmarkZ(b *testing.B) {
    74	b.Logf("LOG: Z running N=%d", b.N)
    75}
    76
    77func BenchmarkXX(b *testing.B) {
    78	b.Logf("LOG: XX running N=%d", b.N)
    79}

View as plain text