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

     1  # Run chatty tests. Assert on CONT lines.
     2  ! go test chatty_test.go -v -bench . chatty_bench
     3  
     4  # Sanity check that output occurs.
     5  stdout -count=2 'this is sub-0'
     6  stdout -count=2 'this is sub-1'
     7  stdout -count=2 'this is sub-2'
     8  stdout -count=1 'error from sub-0'
     9  stdout -count=1 'error from sub-1'
    10  stdout -count=1 'error from sub-2'
    11  
    12  # Benchmarks should not print CONT.
    13  ! stdout CONT
    14  
    15  -- chatty_test.go --
    16  package chatty_bench
    17  
    18  import (
    19  	"testing"
    20  	"fmt"
    21  )
    22  
    23  func BenchmarkChatty(b *testing.B) {
    24      for i := 0; i < 3; i++ {
    25          b.Run(fmt.Sprintf("sub-%d", i), func(b *testing.B) {
    26              for j := 0; j < 2; j++ {
    27                  b.Logf("this is sub-%d", i)
    28              }
    29              b.Errorf("error from sub-%d", i)
    30          })
    31      }
    32  }

View as plain text