| 1 |
env GO111MODULE=on |
| 2 |
[short] skip |
| 3 |
|
| 4 |
# Initially, we are at v1.0.0 for all dependencies. |
| 5 |
go get |
| 6 |
cp go.mod go.mod.orig |
| 7 |
go list -m all |
| 8 |
stdout '^patch.example.com/direct v1.0.0' |
| 9 |
stdout '^patch.example.com/indirect v1.0.0' |
| 10 |
! stdout '^patch.example.com/depofdirectpatch' |
| 11 |
|
| 12 |
# @patch should be rejected for modules not already in the build list. |
| 13 |
! go get patch.example.com/depofdirectpatch@patch |
| 14 |
stderr '^go: can''t query version "patch" of module patch.example.com/depofdirectpatch: no existing version is required$' |
| 15 |
cmp go.mod.orig go.mod |
| 16 |
|
| 17 |
# get -u=patch, with no arguments, should patch-update all dependencies |
| 18 |
# of the package in the current directory, pulling in transitive dependencies |
| 19 |
# and also patching those. |
| 20 |
cp go.mod.orig go.mod |
| 21 |
go get -u=patch |
| 22 |
go list -m all |
| 23 |
stdout '^patch.example.com/direct v1.0.1' |
| 24 |
stdout '^patch.example.com/indirect v1.0.1' |
| 25 |
stdout '^patch.example.com/depofdirectpatch v1.0.0' |
| 26 |
|
| 27 |
# 'get all@patch' should patch the modules that provide packages in 'all'. |
| 28 |
cp go.mod.orig go.mod |
| 29 |
go get all@patch |
| 30 |
go list -m all |
| 31 |
stdout '^patch.example.com/direct v1.0.1' |
| 32 |
stdout '^patch.example.com/indirect v1.0.1' |
| 33 |
stdout '^patch.example.com/depofdirectpatch v1.0.0' |
| 34 |
|
| 35 |
# ...but 'all@patch' should fail if any of the affected modules do not already |
| 36 |
# have a selected version. |
| 37 |
cp go.mod.orig go.mod |
| 38 |
go mod edit -droprequire=patch.example.com/direct |
| 39 |
cp go.mod go.mod.dropped |
| 40 |
! go get all@patch |
| 41 |
stderr '^go: all@patch: can''t query version "patch" of module patch.example.com/direct: no existing version is required$' |
| 42 |
cmp go.mod.dropped go.mod |
| 43 |
|
| 44 |
# Requesting the direct dependency with -u=patch but without an explicit version |
| 45 |
# should patch-update it and its dependencies. |
| 46 |
cp go.mod.orig go.mod |
| 47 |
go get -u=patch patch.example.com/direct |
| 48 |
go list -m all |
| 49 |
stdout '^patch.example.com/direct v1.0.1' |
| 50 |
stdout '^patch.example.com/indirect v1.0.1' |
| 51 |
stdout '^patch.example.com/depofdirectpatch v1.0.0' |
| 52 |
|
| 53 |
# Requesting only the indirect dependency should not update the direct one. |
| 54 |
cp go.mod.orig go.mod |
| 55 |
go get -u=patch patch.example.com/indirect |
| 56 |
go list -m all |
| 57 |
stdout '^patch.example.com/direct v1.0.0' |
| 58 |
stdout '^patch.example.com/indirect v1.0.1' |
| 59 |
! stdout '^patch.example.com/depofdirectpatch' |
| 60 |
|
| 61 |
# @patch should apply only to the specific module, |
| 62 |
# but the result must reflect its upgraded requirements. |
| 63 |
cp go.mod.orig go.mod |
| 64 |
go get patch.example.com/direct@patch |
| 65 |
go list -m all |
| 66 |
stdout '^patch.example.com/direct v1.0.1' |
| 67 |
stdout '^patch.example.com/indirect v1.0.0' |
| 68 |
stdout '^patch.example.com/depofdirectpatch v1.0.0' |
| 69 |
|
| 70 |
# An explicit @patch should override a general -u. |
| 71 |
cp go.mod.orig go.mod |
| 72 |
go get -u patch.example.com/direct@patch |
| 73 |
go list -m all |
| 74 |
stdout '^patch.example.com/direct v1.0.1' |
| 75 |
stdout '^patch.example.com/indirect v1.1.0' |
| 76 |
stdout '^patch.example.com/depofdirectpatch v1.0.0' |
| 77 |
|
| 78 |
# An explicit @latest should override a general -u=patch. |
| 79 |
cp go.mod.orig go.mod |
| 80 |
go get -u=patch patch.example.com/direct@latest |
| 81 |
go list -m all |
| 82 |
stdout '^patch.example.com/direct v1.1.0' |
| 83 |
stdout '^patch.example.com/indirect v1.0.1' |
| 84 |
! stdout '^patch.example.com/depofdirectpatch' |
| 85 |
|
| 86 |
# Standard library packages cannot be upgraded explicitly. |
| 87 |
cp go.mod.orig go.mod |
| 88 |
! go get cmd/vet@patch |
| 89 |
stderr 'go: can''t request explicit version "patch" of standard library package cmd/vet$' |
| 90 |
|
| 91 |
# However, standard-library packages without explicit versions are fine. |
| 92 |
go get -u=patch cmd/go |
| 93 |
|
| 94 |
# We can upgrade to a new version of a module with no root package. |
| 95 |
go get example.com/[email protected] |
| 96 |
go list -m all |
| 97 |
stdout '^example.com/noroot v1.0.0$' |
| 98 |
go get example.com/noroot@patch |
| 99 |
go list -m all |
| 100 |
stdout '^example.com/noroot v1.0.1$' |
| 101 |
|
| 102 |
|
| 103 |
-- go.mod -- |
| 104 |
module x |
| 105 |
|
| 106 |
require patch.example.com/direct v1.0.0 |
| 107 |
|
| 108 |
-- main.go -- |
| 109 |
package x |
| 110 |
import _ "patch.example.com/direct" |