1 # Regression test for golang.org/issue/28481:
2 # 'mod tidy' removed dependencies if the module root was
3 # within a directory named 'testdata' or '_foo'.
4
5 env GO111MODULE=on
6
7 # A module should be allowed in a directory named testdata.
8 cd $WORK/testdata
9 go mod init testdata.tld/foo
10
11 # Getting a package within that module should resolve its dependencies.
12 go get
13 grep 'rsc.io/quote' go.mod
14
15 # Tidying the module should preserve those dependencies.
16 go mod tidy
17 grep 'rsc.io/quote' go.mod
18
19 [short] stop
20
21 # Vendoring the module's dependencies should work too.
22 go mod vendor
23 exists vendor/rsc.io/quote
24
25 # The same should work in directories with names starting with underscores.
26 cd $WORK/_ignored
27 go mod init testdata.tld/foo
28
29 go get
30 grep 'rsc.io/quote' go.mod
31
32 go mod tidy
33 grep 'rsc.io/quote' go.mod
34
35 go mod vendor
36 exists vendor/rsc.io/quote
37
38 -- $WORK/testdata/main.go --
39 package foo
40
41 import _ "rsc.io/quote"
42 -- $WORK/_ignored/main.go --
43 package foo
44
45 import _ "rsc.io/quote"
46
View as plain text