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