Text file src/cmd/go/testdata/script/test_benchmark_chatty_success.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 happens. We don't provide -count because the amount
     5  # of output is variable.
     6  stdout 'this is sub-0'
     7  stdout 'this is sub-1'
     8  stdout 'this is sub-2'
     9  
    10  # Benchmarks should not print CONT.
    11  ! stdout CONT
    12  
    13  -- chatty_test.go --
    14  package chatty_bench
    15  
    16  import (
    17  	"testing"
    18  	"fmt"
    19  )
    20  
    21  func BenchmarkChatty(b *testing.B) {
    22      for i := 0; i < 3; i++ {
    23          b.Run(fmt.Sprintf("sub-%d", i), func(b *testing.B) {
    24              for j := 0; j < 2; j++ {
    25                  b.Logf("this is sub-%d", i)
    26              }
    27          })
    28      }
    29  }

View as plain text