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

View as plain text