aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/list_bad_import.txt
blob: dbec35069c64ea815a5151716afe13fb458e9d27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
env GO111MODULE=off
[short] skip

# This test matches mod_list_bad_import, but in GOPATH mode.
# Please keep them in sync.

env GO111MODULE=off
cd example.com

# Without -e, listing an otherwise-valid package with an unsatisfied direct import should fail.
# BUG: Today it succeeds.
go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}} {{range .DepsErrors}}bad dep: {{.Err}}{{end}}' example.com/direct
! stdout ^error
stdout 'incomplete'
stdout 'bad dep: .*example.com[/\\]notfound'

# Listing with -deps should also fail.
! go list -deps example.com/direct
stderr example.com[/\\]notfound

# But -e -deps should succeed.
go list -e -deps example.com/direct
stdout example.com/notfound


# Listing an otherwise-valid package that imports some *other* package with an
# unsatisfied import should also fail.
# BUG: Today, it succeeds.
go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}} {{range .DepsErrors}}bad dep: {{.Err}}{{end}}' example.com/indirect
! stdout ^error
stdout incomplete
stdout 'bad dep: .*example.com[/\\]notfound'

# Again, -deps should fail.
! go list -deps example.com/indirect
stderr example.com[/\\]notfound

# But -deps -e should succeed.
go list -e -deps example.com/indirect
stdout example.com/notfound


# Listing the missing dependency directly should fail outright...
! go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}}' example.com/notfound
stderr 'no Go files in .*example.com[/\\]notfound'
! stdout error
! stdout incomplete

# ...but listing with -e should succeed.
go list -e -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}}' example.com/notfound
stdout error
stdout incomplete


# The pattern "all" should match only packages that actually exist,
# ignoring those whose existence is merely implied by imports.
go list -e -f '{{.ImportPath}}' all
stdout example.com/direct
stdout example.com/indirect
! stdout example.com/notfound


-- example.com/direct/direct.go --
package direct
import _ "example.com/notfound"

-- example.com/indirect/indirect.go --
package indirect
import _ "example.com/direct"

-- example.com/notfound/README --
This directory intentionally left blank.