...

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

Documentation: cmd/go/testdata/script

     1[!fuzz] skip
     2[short] skip
     3env GOCACHE=$WORK/cache
     4
     5# Run chatty fuzz targets with an error.
     6! go test -v chatty_error_fuzz_test.go
     7! stdout '^ok'
     8stdout 'FAIL'
     9stdout 'error in target'
    10
    11# Run chatty fuzz targets with a fatal.
    12! go test -v chatty_fatal_fuzz_test.go
    13! stdout '^ok'
    14stdout 'FAIL'
    15stdout 'fatal in target'
    16
    17# Run chatty fuzz target with a panic
    18! go test -v chatty_panic_fuzz_test.go
    19! stdout ^ok
    20stdout FAIL
    21stdout 'this is bad'
    22
    23# Run skipped chatty fuzz targets.
    24go test -v chatty_skipped_fuzz_test.go
    25stdout ok
    26stdout SKIP
    27! stdout FAIL
    28
    29# Run successful chatty fuzz targets.
    30go test -v chatty_fuzz_test.go
    31stdout ok
    32stdout PASS
    33stdout 'all good here'
    34! stdout FAIL
    35
    36# Fuzz successful chatty fuzz target that includes a separate unit test.
    37go test -v chatty_with_test_fuzz_test.go -fuzz=Fuzz -fuzztime=1x
    38stdout ok
    39stdout PASS
    40! stdout FAIL
    41stdout -count=1 'all good here'
    42# Verify that the unit test is only run once.
    43stdout -count=1 'logged foo'
    44
    45-- chatty_error_fuzz_test.go --
    46package chatty_error_fuzz
    47
    48import "testing"
    49
    50func Fuzz(f *testing.F) {
    51    f.Error("error in target")
    52}
    53
    54-- chatty_fatal_fuzz_test.go --
    55package chatty_fatal_fuzz
    56
    57import "testing"
    58
    59func Fuzz(f *testing.F) {
    60    f.Fatal("fatal in target")
    61}
    62
    63-- chatty_panic_fuzz_test.go --
    64package chatty_panic_fuzz
    65
    66import "testing"
    67
    68func Fuzz(f *testing.F) {
    69    panic("this is bad")
    70}
    71
    72-- chatty_skipped_fuzz_test.go --
    73package chatty_skipped_fuzz
    74
    75import "testing"
    76
    77func Fuzz(f *testing.F) {
    78    f.Skip()
    79}
    80
    81-- chatty_fuzz_test.go --
    82package chatty_fuzz
    83
    84import "testing"
    85
    86func Fuzz(f *testing.F) {
    87    f.Log("all good here")
    88    f.Fuzz(func(*testing.T, []byte) {})
    89}
    90
    91-- chatty_with_test_fuzz_test.go --
    92package chatty_with_test_fuzz
    93
    94import "testing"
    95
    96func TestFoo(t *testing.T) {
    97    t.Log("logged foo")
    98}
    99
   100func Fuzz(f *testing.F) {
   101    f.Log("all good here")
   102    f.Fuzz(func(*testing.T, []byte) {})
   103}

View as plain text