...

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

Documentation: cmd/go/testdata/script

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

View as plain text