...
1env GO111MODULE=off
2[short] skip
3
4# This test matches mod_list_bad_import, but in GOPATH mode.
5# Please keep them in sync.
6
7env GO111MODULE=off
8cd example.com
9
10# Without -e, listing an otherwise-valid package with an unsatisfied direct import should fail.
11# BUG: Today it succeeds.
12go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}} {{range .DepsErrors}}bad dep: {{.Err}}{{end}}' example.com/direct
13! stdout ^error
14stdout 'incomplete'
15stdout 'bad dep: .*example.com[/\\]notfound'
16
17# Listing with -deps should also fail.
18! go list -deps example.com/direct
19stderr example.com[/\\]notfound
20
21# But -e -deps should succeed.
22go list -e -deps example.com/direct
23stdout example.com/notfound
24
25
26# Listing an otherwise-valid package that imports some *other* package with an
27# unsatisfied import should also fail.
28# BUG: Today, it succeeds.
29go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}} {{range .DepsErrors}}bad dep: {{.Err}}{{end}}' example.com/indirect
30! stdout ^error
31stdout incomplete
32stdout 'bad dep: .*example.com[/\\]notfound'
33
34# Again, -deps should fail.
35! go list -deps example.com/indirect
36stderr example.com[/\\]notfound
37
38# But -deps -e should succeed.
39go list -e -deps example.com/indirect
40stdout example.com/notfound
41
42
43# Listing the missing dependency directly should fail outright...
44! go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}}' example.com/notfound
45stderr 'no Go files in .*example.com[/\\]notfound'
46! stdout error
47! stdout incomplete
48
49# ...but listing with -e should succeed.
50go list -e -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}}' example.com/notfound
51stdout error
52stdout incomplete
53
54
55# The pattern "all" should match only packages that actually exist,
56# ignoring those whose existence is merely implied by imports.
57go list -e -f '{{.ImportPath}}' all
58stdout example.com/direct
59stdout example.com/indirect
60! stdout example.com/notfound
61
62
63-- example.com/direct/direct.go --
64package direct
65import _ "example.com/notfound"
66
67-- example.com/indirect/indirect.go --
68package indirect
69import _ "example.com/direct"
70
71-- example.com/notfound/README --
72This directory intentionally left blank.
View as plain text