...

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

Documentation: cmd/go/testdata/script

     1[compiler:gccgo] skip # gccgo does not have standard packages
     2[short] skip
     3
     4env GOCACHE=$WORK/tmp
     5
     6# Run go test -json on errors m/empty/pkg and m/skipper
     7# It would be nice to test that the output is interlaced
     8# but it seems to be impossible to do that in a short test
     9# that isn't also flaky. Just check that we get JSON output.
    10go test -json -short -v errors m/empty/pkg m/skipper
    11
    12# Check errors for run action
    13stdout '"Package":"errors"'
    14stdout '"Action":"start","Package":"errors"'
    15stdout '"Action":"run","Package":"errors"'
    16
    17# Check m/empty/pkg for output and skip actions
    18stdout '"Action":"start","Package":"m/empty/pkg"'
    19stdout '"Action":"output","Package":"m/empty/pkg","Output":".*no test files'
    20stdout '"Action":"skip","Package":"m/empty/pkg"'
    21
    22# Check skipper for output and skip actions
    23stdout '"Action":"start","Package":"m/skipper"'
    24stdout '"Action":"output","Package":"m/skipper","Test":"Test","Output":"--- SKIP:'
    25stdout '"Action":"skip","Package":"m/skipper","Test":"Test"'
    26
    27# Check that starts were ordered properly.
    28stdout '(?s)"Action":"start","Package":"errors".*"Action":"start","Package":"m/empty/pkg".*"Action":"start","Package":"m/skipper"'
    29
    30# Run go test -json on errors and check it's cached
    31go test -json -short -v errors
    32stdout '"Action":"output","Package":"errors","Output":".*\(cached\)'
    33
    34go test -json -bench=NONE -short -v errors
    35stdout '"Package":"errors"'
    36stdout '"Action":"run"'
    37
    38# Test running test2json
    39go test -o $WORK/tmp/errors.test$GOEXE -c errors
    40go tool test2json -p errors $WORK/tmp/errors.test$GOEXE -test.v -test.short
    41stdout '"Package":"errors"'
    42stdout '"Action":"run"'
    43stdout '\{"Action":"pass","Package":"errors"\}'
    44
    45-- go.mod --
    46module m
    47
    48go 1.16
    49-- skipper/skip_test.go --
    50package skipper
    51
    52import "testing"
    53
    54func Test(t *testing.T) {
    55	t.Skip("skipping")
    56}
    57-- empty/pkg/pkg.go --
    58package p
    59-- empty/pkgtest/pkg.go --
    60package p
    61-- empty/pkgtest/test_test.go --
    62package p
    63-- empty/pkgtestxtest/pkg.go --
    64package p
    65-- empty/pkgtestxtest/test_test.go --
    66package p
    67-- empty/pkgtestxtest/xtest_test.go --
    68package p_test
    69-- empty/pkgxtest/pkg.go --
    70package p
    71-- empty/pkgxtest/xtest_test.go --
    72package p_test
    73-- empty/test/test_test.go --
    74package p
    75-- empty/testxtest/test_test.go --
    76package p
    77-- empty/testxtest/xtest_test.go --
    78package p_test
    79-- empty/xtest/xtest_test.go --
    80package p_test

View as plain text