github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/go/testdata/script/mod_test.txt (about)

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