...

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

Documentation: cmd/go/testdata/script

     1# Run chatty tests. Assert on CONT lines.
     2go 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.
     6stdout 'this is sub-0'
     7stdout 'this is sub-1'
     8stdout 'this is sub-2'
     9
    10# Benchmarks should not print CONT.
    11! stdout CONT
    12
    13-- chatty_test.go --
    14package chatty_bench
    15
    16import (
    17	"testing"
    18	"fmt"
    19)
    20
    21func 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