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