| cp go.mod go.mod.orig |
| |
| |
| # If a dependency cannot be resolved, 'go mod tidy' fails with an error message |
| # explaining the problem and does not update the go.mod file. |
| # TODO(bcmills): Ideally, with less redundancy than these error messages! |
| |
| ! go mod tidy |
| |
| stderr '^example.com/untidy imports\n\texample.net/directnotfound: cannot find module providing package example.net/directnotfound: module example.net/directnotfound: reading http://.*: 404 Not Found$' |
| |
| stderr '^example.com/untidy imports\n\texample.net/m imports\n\texample.net/indirectnotfound: cannot find module providing package example.net/indirectnotfound: module example.net/indirectnotfound: reading http://.*: 404 Not Found$' |
| |
| stderr '^example.com/untidy tested by\n\texample.com/untidy.test imports\n\texample.net/directtestnotfound: cannot find module providing package example.net/directtestnotfound: module example.net/directtestnotfound: reading http://.*: 404 Not Found$' |
| |
| stderr '^example.com/untidy imports\n\texample.net/m tested by\n\texample.net/m.test imports\n\texample.net/indirecttestnotfound: cannot find module providing package example.net/indirecttestnotfound: module example.net/indirecttestnotfound: reading http://.*: 404 Not Found$' |
| |
| cmp go.mod.orig go.mod |
| |
| |
| # If a dependency cannot be resolved, 'go mod vendor' fails with an error message |
| # explaining the problem, does not update the go.mod file, and does not create |
| # the vendor directory. |
| |
| ! go mod vendor |
| |
| stderr '^example.com/untidy imports\n\texample.net/directnotfound: cannot find module providing package example.net/directnotfound: module example.net/directnotfound: reading http://.*: 404 Not Found$' |
| |
| stderr '^example.com/untidy imports\n\texample.net/m imports\n\texample.net/indirectnotfound: cannot find module providing package example.net/indirectnotfound: module example.net/indirectnotfound: reading http://.*: 404 Not Found$' |
| |
| stderr '^example.com/untidy tested by\n\texample.com/untidy.test imports\n\texample.net/directtestnotfound: cannot find module providing package example.net/directtestnotfound: module example.net/directtestnotfound: reading http://.*: 404 Not Found$' |
| |
| ! stderr 'indirecttestnotfound' # Vendor prunes test dependencies. |
| |
| cmp go.mod.orig go.mod |
| ! exists vendor |
| |
| |
| # 'go mod tidy' still logs the errors, but succeeds and updates go.mod. |
| |
| go mod tidy -e |
| stderr -count=4 'cannot find module providing package' |
| cmp go.mod.final go.mod |
| |
| |
| # 'go mod vendor -e' still logs the errors, but succeeds and updates go.mod. |
| |
| cp go.mod.orig go.mod |
| go mod vendor -e |
| stderr -count=3 'cannot find module providing package' |
| cmp go.mod.final go.mod |
| exists vendor/modules.txt |
| exists vendor/example.net/m/m.go |
| |
| |
| -- go.mod -- |
| module example.com/untidy |
| go 1.16 |
| replace example.net/m v0.1.0 => ./m |
| -- go.mod.final -- |
| module example.com/untidy |
| |
| go 1.16 |
| |
| replace example.net/m v0.1.0 => ./m |
| |
| require example.net/m v0.1.0 |
| -- untidy.go -- |
| package untidy |
| |
| import ( |
| _ "example.net/m" |
| _ "example.net/directnotfound" |
| ) |
| -- untidy_test.go -- |
| package untidy_test |
| |
| import _ "example.net/directtestnotfound" |
| -- m/go.mod -- |
| module example.net/m |
| go 1.16 |
| -- m/m.go -- |
| package m |
| |
| import _ "example.net/indirectnotfound" |
| -- m/m_test.go -- |
| package m_test |
| |
| import _ "example.net/indirecttestnotfound" |