...

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

Documentation: cmd/go/testdata/script

     1env GO111MODULE=off
     2
     3# issue 28491: errors in test source files should not prevent
     4# "go list -test" from returning useful information.
     5
     6# go list -e prints information for all test packages.
     7# The syntax error is shown in the package error field.
     8go list -e -test -deps -f '{{.ImportPath}} {{.Error | printf "%q"}}' syntaxerr
     9stdout 'pkgdep <nil>'
    10stdout 'testdep_a <nil>'
    11stdout 'testdep_b <nil>'
    12stdout 'syntaxerr <nil>'
    13stdout 'syntaxerr \[syntaxerr.test\] <nil>'
    14stdout 'syntaxerr_test \[syntaxerr.test\] <nil>'
    15stdout 'syntaxerr\.test "[^"]*expected declaration'
    16! stderr 'expected declaration'
    17
    18[short] stop
    19
    20go list -e -test -deps -f '{{.ImportPath}} {{.Error | printf "%q"}}' nameerr
    21stdout 'pkgdep <nil>'
    22stdout 'testdep_a <nil>'
    23stdout 'testdep_b <nil>'
    24stdout 'nameerr\.test "[^"]*wrong signature for TestBad'
    25! stderr 'wrong signature for TestBad'
    26
    27# go list prints a useful error for generic test functions
    28! go list -test -deps genericerr
    29stderr 'wrong signature for TestGeneric, test functions cannot have type parameters'
    30
    31go list -e -test -deps -f '{{.ImportPath}} {{.Error | printf "%q"}}' cycleerr
    32stdout 'cycleerr <nil>'
    33stdout 'testdep_a <nil>'
    34stdout 'testdep_cycle \[cycleerr.test\] <nil>'
    35stdout 'cycleerr \[cycleerr.test\] "[^"]*import cycle not allowed in test'
    36! stderr 'import cycle not allowed in test'
    37
    38-- syntaxerr/syntaxerr.go --
    39package syntaxerr
    40
    41import _ "pkgdep"
    42
    43-- syntaxerr/syntaxerr_ie_test.go --
    44package syntaxerr
    45
    46!!!syntax error
    47
    48-- syntaxerr/syntaxerr_xe_test.go --
    49package syntaxerr_test
    50
    51!!!syntax error
    52
    53-- syntaxerr/syntaxerr_i_test.go --
    54package syntaxerr
    55
    56import _ "testdep_a"
    57
    58-- syntaxerr/syntaxerr_x_test.go --
    59package syntaxerr
    60
    61import _ "testdep_b"
    62
    63-- nameerr/nameerr.go --
    64package nameerr
    65
    66import _ "pkgdep"
    67
    68-- nameerr/nameerr_i_test.go --
    69package nameerr
    70
    71import (
    72  _ "testdep_a"
    73  "testing"
    74)
    75
    76func TestBad(t *testing.B) {}
    77
    78-- nameerr/nameerr_x_test.go --
    79package nameerr_test
    80
    81import (
    82  _ "testdep_b"
    83  "testing"
    84)
    85
    86func TestBad(t *testing.B) {}
    87
    88-- genericerr/genericerr.go --
    89package genericerr
    90
    91-- genericerr/genericerr_test.go --
    92package genericerr
    93
    94import "testing"
    95
    96func TestGeneric[T any](t *testing.T) {}
    97
    98-- cycleerr/cycleerr_test.go --
    99package cycleerr
   100
   101import (
   102  _ "testdep_a"
   103  _ "testdep_cycle"
   104)
   105
   106-- pkgdep/pkgdep.go --
   107package pkgdep
   108
   109-- testdep_a/testdep_a.go --
   110package testdep_a
   111
   112-- testdep_b/testdep_b.go --
   113package testdep_b
   114
   115-- testdep_cycle/testdep_cycle.go --
   116package testdep_cycle
   117
   118import _ "cycleerr"

View as plain text