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

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

View as plain text