| 1 |
env 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 |
|
| 7 |
env GO111MODULE=off |
| 8 |
cd example.com |
| 9 |
|
| 10 |
# Without -e, listing an otherwise-valid package with an unsatisfied direct import should fail. |
| 11 |
# BUG: Today it succeeds. |
| 12 |
go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}} {{range .DepsErrors}}bad dep: {{.Err}}{{end}}' example.com/direct |
| 13 |
! stdout ^error |
| 14 |
stdout 'incomplete' |
| 15 |
stdout 'bad dep: .*example.com[/\\]notfound' |
| 16 |
|
| 17 |
# Listing with -deps should also fail. |
| 18 |
! go list -deps example.com/direct |
| 19 |
stderr example.com[/\\]notfound |
| 20 |
|
| 21 |
# But -e -deps should succeed. |
| 22 |
go list -e -deps example.com/direct |
| 23 |
stdout 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. |
| 29 |
go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}} {{range .DepsErrors}}bad dep: {{.Err}}{{end}}' example.com/indirect |
| 30 |
! stdout ^error |
| 31 |
stdout incomplete |
| 32 |
stdout 'bad dep: .*example.com[/\\]notfound' |
| 33 |
|
| 34 |
# Again, -deps should fail. |
| 35 |
! go list -deps example.com/indirect |
| 36 |
stderr example.com[/\\]notfound |
| 37 |
|
| 38 |
# But -deps -e should succeed. |
| 39 |
go list -e -deps example.com/indirect |
| 40 |
stdout 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 |
| 45 |
stderr 'no Go files in .*example.com[/\\]notfound' |
| 46 |
! stdout error |
| 47 |
! stdout incomplete |
| 48 |
|
| 49 |
# ...but listing with -e should succeed. |
| 50 |
go list -e -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}}' example.com/notfound |
| 51 |
stdout error |
| 52 |
stdout incomplete |
| 53 |
|
| 54 |
|
| 55 |
# The pattern "all" should match only packages that actually exist, |
| 56 |
# ignoring those whose existence is merely implied by imports. |
| 57 |
go list -e -f '{{.ImportPath}}' all |
| 58 |
stdout example.com/direct |
| 59 |
stdout example.com/indirect |
| 60 |
! stdout example.com/notfound |
| 61 |
|
| 62 |
|
| 63 |
-- example.com/direct/direct.go -- |
| 64 |
package direct |
| 65 |
import _ "example.com/notfound" |
| 66 |
|
| 67 |
-- example.com/indirect/indirect.go -- |
| 68 |
package indirect |
| 69 |
import _ "example.com/direct" |
| 70 |
|
| 71 |
-- example.com/notfound/README -- |
| 72 |
This directory intentionally left blank. |