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

     1  env 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 prints information for package, internal test,
     7  # external test, but not testmain package when there is a
     8  # syntax error in test sources.
     9  ! go list -test -deps syntaxerr
    10  stdout pkgdep
    11  stdout testdep_a
    12  stdout testdep_b
    13  stdout ^syntaxerr$
    14  stdout '^syntaxerr \[syntaxerr.test\]'
    15  stdout '^syntaxerr_test \[syntaxerr.test\]'
    16  ! stdout '^syntaxerr\.test'
    17  stderr 'expected declaration'
    18  
    19  # go list -e prints information for all test packages.
    20  # The syntax error is shown in the package error field.
    21  go list -e -test -deps -f '{{.ImportPath}} {{.Error | printf "%q"}}' syntaxerr
    22  stdout 'pkgdep <nil>'
    23  stdout 'testdep_a <nil>'
    24  stdout 'testdep_b <nil>'
    25  stdout 'syntaxerr <nil>'
    26  stdout 'syntaxerr \[syntaxerr.test\] <nil>'
    27  stdout 'syntaxerr_test \[syntaxerr.test\] <nil>'
    28  stdout 'syntaxerr\.test "[^"]*expected declaration'
    29  ! stderr 'expected declaration'
    30  
    31  [short] stop
    32  
    33  # go list prints partial information with test naming error
    34  ! go list -test -deps nameerr
    35  stdout pkgdep
    36  stdout testdep_a
    37  stdout testdep_b
    38  stderr 'wrong signature for TestBad'
    39  
    40  go list -e -test -deps -f '{{.ImportPath}} {{.Error | printf "%q"}}' nameerr
    41  stdout 'pkgdep <nil>'
    42  stdout 'testdep_a <nil>'
    43  stdout 'testdep_b <nil>'
    44  stdout 'nameerr\.test "[^"]*wrong signature for TestBad'
    45  ! stderr 'wrong signature for TestBad'
    46  
    47  # go list prints a useful error for generic test functions
    48  ! go list -test -deps genericerr
    49  stderr 'wrong signature for TestGeneric, test functions cannot have type parameters'
    50  
    51  # go list prints partial information with error if test has cyclic import
    52  ! go list -test -deps cycleerr
    53  stdout cycleerr
    54  stderr 'import cycle not allowed in test'
    55  
    56  go list -e -test -deps -f '{{.ImportPath}} {{.Error | printf "%q"}}' cycleerr
    57  stdout 'cycleerr <nil>'
    58  stdout 'testdep_a <nil>'
    59  stdout 'testdep_cycle <nil>'
    60  stdout 'cycleerr \[cycleerr.test\] "[^"]*import cycle not allowed in test'
    61  ! stderr 'import cycle not allowed in test'
    62  
    63  -- syntaxerr/syntaxerr.go --
    64  package syntaxerr
    65  
    66  import _ "pkgdep"
    67  
    68  -- syntaxerr/syntaxerr_ie_test.go --
    69  package syntaxerr
    70  
    71  !!!syntax error
    72  
    73  -- syntaxerr/syntaxerr_xe_test.go --
    74  package syntaxerr_test
    75  
    76  !!!syntax error
    77  
    78  -- syntaxerr/syntaxerr_i_test.go --
    79  package syntaxerr
    80  
    81  import _ "testdep_a"
    82  
    83  -- syntaxerr/syntaxerr_x_test.go --
    84  package syntaxerr
    85  
    86  import _ "testdep_b"
    87  
    88  -- nameerr/nameerr.go --
    89  package nameerr
    90  
    91  import _ "pkgdep"
    92  
    93  -- nameerr/nameerr_i_test.go --
    94  package nameerr
    95  
    96  import (
    97    _ "testdep_a"
    98    "testing"
    99  )
   100  
   101  func TestBad(t *testing.B) {}
   102  
   103  -- nameerr/nameerr_x_test.go --
   104  package nameerr_test
   105  
   106  import (
   107    _ "testdep_b"
   108    "testing"
   109  )
   110  
   111  func TestBad(t *testing.B) {}
   112  
   113  -- genericerr/genericerr.go --
   114  package genericerr
   115  
   116  -- genericerr/genericerr_test.go --
   117  package genericerr
   118  
   119  import "testing"
   120  
   121  func TestGeneric[T any](t *testing.T) {}
   122  
   123  -- cycleerr/cycleerr_test.go --
   124  package cycleerr
   125  
   126  import (
   127    _ "testdep_a"
   128    _ "testdep_cycle"
   129  )
   130  
   131  -- pkgdep/pkgdep.go --
   132  package pkgdep
   133  
   134  -- testdep_a/testdep_a.go --
   135  package testdep_a
   136  
   137  -- testdep_b/testdep_b.go --
   138  package testdep_b
   139  
   140  -- testdep_cycle/testdep_cycle.go --
   141  package testdep_cycle
   142  
   143  import _ "cycleerr"
   144  

View as plain text