...

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

Documentation: cmd/go/testdata/script

     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.
     5stdout -count=2 'this is sub-0'
     6stdout -count=2 'this is sub-1'
     7stdout -count=2 'this is sub-2'
     8stdout -count=1 'error from sub-0'
     9stdout -count=1 'error from sub-1'
    10stdout -count=1 'error from sub-2'
    11
    12# Benchmarks should not print CONT.
    13! stdout CONT
    14
    15-- chatty_test.go --
    16package chatty_bench
    17
    18import (
    19	"testing"
    20	"fmt"
    21)
    22
    23func 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