github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_test.txt (about)

     1  env GO111MODULE=on
     2  [short] skip
     3  
     4  # TODO(bcmills): Convert the 'go test' calls below to 'go list -test' once 'go
     5  # list' is more sensitive to package loading errors.
     6  
     7  # A test in the module's root package should work.
     8  cd a/
     9  cp go.mod.empty go.mod
    10  go list -test
    11  ! stderr error
    12  
    13  cp go.mod.empty go.mod
    14  go list -deps
    15  ! stdout ^testing$
    16  
    17  # list all should include test dependencies, like testing
    18  cp go.mod.empty go.mod
    19  go list all
    20  stdout ^testing$
    21  stdout ^rsc.io/quote$
    22  stdout ^rsc.io/testonly$
    23  
    24  # list -deps -tests should also include testing
    25  # but not deps of tests of deps (rsc.io/testonly).
    26  go list -deps -test
    27  stdout ^testing$
    28  stdout ^rsc.io/quote$
    29  ! stdout ^rsc.io/testonly$
    30  
    31  # list -test all should succeed
    32  cp go.mod.empty go.mod
    33  go list -test all
    34  stdout '^testing'
    35  
    36  cp go.mod.empty go.mod
    37  go list -test
    38  ! stderr error
    39  
    40  # A test with the "_test" suffix in the module root should also work.
    41  cd ../b/
    42  go list -test
    43  ! stderr error
    44  
    45  # A test with the "_test" suffix of a *package* with a "_test" suffix should
    46  # even work (not that you should ever do that).
    47  cd ../c_test
    48  go list -test
    49  ! stderr error
    50  
    51  cd ../d_test
    52  go list -test
    53  ! stderr error
    54  
    55  cd ../e
    56  go list -test
    57  ! stderr error
    58  
    59  -- a/go.mod.empty --
    60  module example.com/user/a
    61  
    62  -- a/a.go --
    63  package a
    64  
    65  -- a/a_test.go --
    66  package a
    67  
    68  import "testing"
    69  import _ "rsc.io/quote"
    70  
    71  func Test(t *testing.T) {}
    72  
    73  -- b/go.mod --
    74  module example.com/user/b
    75  
    76  -- b/b.go --
    77  package b
    78  
    79  -- b/b_test.go --
    80  package b_test
    81  
    82  import "testing"
    83  
    84  func Test(t *testing.T) {}
    85  
    86  -- c_test/go.mod --
    87  module example.com/c_test
    88  
    89  -- c_test/umm.go --
    90  // Package c_test is the non-test package for its import path!
    91  package c_test
    92  
    93  -- c_test/c_test_test.go --
    94  package c_test_test
    95  
    96  import "testing"
    97  
    98  func Test(t *testing.T) {}
    99  
   100  -- d_test/go.mod --
   101  // Package d is an ordinary package in a deceptively-named directory.
   102  module example.com/d
   103  
   104  -- d_test/d.go --
   105  package d
   106  
   107  -- d_test/d_test.go --
   108  package d_test
   109  
   110  import "testing"
   111  
   112  func Test(t *testing.T) {}
   113  
   114  -- e/go.mod --
   115  module example.com/e_test
   116  
   117  -- e/wat.go --
   118  // Package e_test is the non-test package for its import path,
   119  // in a deceptively-named directory!
   120  package e_test
   121  
   122  -- e/e_test.go --
   123  package e_test_test
   124  
   125  import "testing"
   126  
   127  func Test(t *testing.T) {}