diff options
Diffstat (limited to 'src/cmd/go/testdata')
8 files changed, 319 insertions, 14 deletions
diff --git a/src/cmd/go/testdata/script/mod_get_boost.txt b/src/cmd/go/testdata/script/mod_get_boost.txt new file mode 100644 index 0000000000..105dc2e2b3 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_get_boost.txt @@ -0,0 +1,96 @@ +# If 'go get -u' finds an upgrade candidate that isn't viable, +# but some other upgraded module's requirement moves past it +# (for example, to a higher prerelease), then we should accept +# the transitive upgrade instead of trying lower roots. + +go get -v -u . example.net/b@v0.1.0 +cmp go.mod go.mod.want + +-- go.mod -- +module example + +go 1.17 + +require ( + example.net/a v0.1.0 + example.net/b v0.1.0 + example.net/c v0.1.0 +) + +replace ( + example.net/a v0.1.0 => ./a1 + example.net/a v0.2.0-pre => ./a2p + example.net/b v0.1.0 => ./b + example.net/b v0.2.0 => ./b + example.net/c v0.1.0 => ./c1 + example.net/c v0.2.0 => ./c2 +) +-- go.mod.want -- +module example + +go 1.17 + +require ( + example.net/a v0.2.0-pre + example.net/b v0.1.0 + example.net/c v0.2.0 +) + +replace ( + example.net/a v0.1.0 => ./a1 + example.net/a v0.2.0-pre => ./a2p + example.net/b v0.1.0 => ./b + example.net/b v0.2.0 => ./b + example.net/c v0.1.0 => ./c1 + example.net/c v0.2.0 => ./c2 +) +-- example.go -- +package example + +import ( + _ "example.net/a" + _ "example.net/b" + _ "example.net/c" +) +-- a1/go.mod -- +module example.net/a + +go 1.17 + +require example.net/b v0.2.0 +-- a1/a.go -- +package a + +import _ "example.net/b" +-- a2p/go.mod -- +module example.net/a + +go 1.17 +-- a2p/a.go -- +package a +-- b/go.mod -- +module example.net/b + +go 1.17 +-- b/b.go -- +package b +-- c1/go.mod -- +module example.net/c + +go 1.17 + +require example.net/a v0.1.0 +-- c1/c.go -- +package c + +import _ "example.net/a" +-- c2/go.mod -- +module example.net/c + +go 1.17 + +require example.net/a v0.2.0-pre +-- c2/c.go -- +package c + +import _ "example.net/c" diff --git a/src/cmd/go/testdata/script/mod_get_downup_indirect.txt b/src/cmd/go/testdata/script/mod_get_downup_indirect.txt index 3a46a774ce..432e626003 100644 --- a/src/cmd/go/testdata/script/mod_get_downup_indirect.txt +++ b/src/cmd/go/testdata/script/mod_get_downup_indirect.txt @@ -19,17 +19,31 @@ # # If we downgrade module d to version 1, we must downgrade b as well. # If that downgrade selects b version 1, we will upgrade module c to version 2. -# So 'go get d@1' should instead downgrade both b and c to "none". cp go.mod go.mod.orig go mod tidy cmp go.mod.orig go.mod +# Downgrading d to version 1 downgrades b, which upgrades c. go get example.com/d@v0.1.0 go list -m all -! stdout '^example.com/b ' -! stdout '^example.com/c ' +stdout '^example.com/b v0.1.0 ' +stdout '^example.com/c v0.2.0 ' stdout '^example.com/d v0.1.0 ' +cmp go.mod go.mod.down1 + +# Restoring c to version 1 upgrades d to meet c's requirements. +go get example.com/c@v0.1.0 +go list -m all +! stdout '^example.com/b ' +stdout '^example.com/c v0.1.0 ' +stdout '^example.com/d v0.2.0 ' +cmp go.mod go.mod.down2 + +# If a user explicitly requests the incompatible versions together, +# 'go get' should explain why they are not compatible. +! go get example.com/c@v0.1.0 example.com/d@v0.1.0 +stderr '^go: example\.com/c@v0\.1\.0 requires example\.com/d@v0\.2\.0, not example\.com/d@v0\.1\.0' -- go.mod -- module example.com/a @@ -49,6 +63,40 @@ replace ( example.com/d v0.1.0 => ./d example.com/d v0.2.0 => ./d ) +-- go.mod.down1 -- +module example.com/a + +go 1.15 + +require ( + example.com/b v0.1.0 + example.com/c v0.2.0 + example.com/d v0.1.0 // indirect +) + +replace ( + example.com/b v0.1.0 => ./b1 + example.com/b v0.2.0 => ./b2 + example.com/c v0.1.0 => ./c1 + example.com/c v0.2.0 => ./c2 + example.com/d v0.1.0 => ./d + example.com/d v0.2.0 => ./d +) +-- go.mod.down2 -- +module example.com/a + +go 1.15 + +require example.com/c v0.1.0 + +replace ( + example.com/b v0.1.0 => ./b1 + example.com/b v0.2.0 => ./b2 + example.com/c v0.1.0 => ./c1 + example.com/c v0.2.0 => ./c2 + example.com/d v0.1.0 => ./d + example.com/d v0.2.0 => ./d +) -- a.go -- package a diff --git a/src/cmd/go/testdata/script/mod_get_downup_indirect_pruned.txt b/src/cmd/go/testdata/script/mod_get_downup_indirect_pruned.txt new file mode 100644 index 0000000000..cac6b96790 --- /dev/null +++ b/src/cmd/go/testdata/script/mod_get_downup_indirect_pruned.txt @@ -0,0 +1,154 @@ +# This test illustrates a case where downgrading one module may upgrade another. +# This is the same as mod_get_downup_indirect, but using modules +# with graph pruning enabled (go ≥ 1.17). +# Compare to the downcross1 test case in cmd/go/internal/mvs/mvs_test.go. + +# The package import graph used in this test looks like: +# +# a ---- b +# \ \ +# \ \ +# ----- c ---- d +# +# The module dependency graph originally looks like: +# +# a ---- b.2 +# \ \ +# \ \ +# ----- c.1 ---- d.2 +# +# b.1 ---- c.2 +# +# If we downgrade module d to version 1, we must downgrade b as well. +# If that downgrade selects b version 1, we will upgrade module c to version 2. + +cp go.mod go.mod.orig +go mod tidy +cmp go.mod.orig go.mod + +# Downgrading d to version 1 downgrades b, which upgrades c. +go get -v example.com/d@v0.1.0 +go list -m all +stdout '^example.com/b v0.1.0 ' +stdout '^example.com/c v0.2.0 ' +stdout '^example.com/d v0.1.0 ' +cmp go.mod go.mod.down1 + +# Restoring c to version 1 upgrades d to meet c's requirements. +go get example.com/c@v0.1.0 +go list -m all +! stdout '^example.com/b ' +stdout '^example.com/c v0.1.0 ' +stdout '^example.com/d v0.2.0 ' +cmp go.mod go.mod.down2 + +# If a user explicitly requests the incompatible versions together, +# 'go get' should explain why they are not compatible. +! go get example.com/c@v0.1.0 example.com/d@v0.1.0 +stderr '^go: example\.com/c@v0\.1\.0 requires example\.com/d@v0\.2\.0, not example\.com/d@v0\.1\.0' + +-- go.mod -- +module example.com/a + +go 1.17 + +require ( + example.com/b v0.2.0 + example.com/c v0.1.0 +) + +replace ( + example.com/b v0.1.0 => ./b1 + example.com/b v0.2.0 => ./b2 + example.com/c v0.1.0 => ./c1 + example.com/c v0.2.0 => ./c2 + example.com/d v0.1.0 => ./d + example.com/d v0.2.0 => ./d +) +-- go.mod.down1 -- +module example.com/a + +go 1.17 + +require ( + example.com/b v0.1.0 + example.com/c v0.2.0 +) + +require example.com/d v0.1.0 // indirect + +replace ( + example.com/b v0.1.0 => ./b1 + example.com/b v0.2.0 => ./b2 + example.com/c v0.1.0 => ./c1 + example.com/c v0.2.0 => ./c2 + example.com/d v0.1.0 => ./d + example.com/d v0.2.0 => ./d +) +-- go.mod.down2 -- +module example.com/a + +go 1.17 + +require example.com/c v0.1.0 + +require example.com/d v0.2.0 // indirect + +replace ( + example.com/b v0.1.0 => ./b1 + example.com/b v0.2.0 => ./b2 + example.com/c v0.1.0 => ./c1 + example.com/c v0.2.0 => ./c2 + example.com/d v0.1.0 => ./d + example.com/d v0.2.0 => ./d +) +-- a.go -- +package a + +import ( + _ "example.com/b" + _ "example.com/c" +) + +-- b1/go.mod -- +module example.com/b + +go 1.17 + +require example.com/c v0.2.0 +-- b1/b.go -- +package b + +import _ "example.com/c" + +-- b2/go.mod -- +module example.com/b + +go 1.17 + +require example.com/c v0.1.0 +-- b2/b.go -- +package b + +import _ "example.com/c" + +-- c1/go.mod -- +module example.com/c + +go 1.17 + +require example.com/d v0.2.0 +-- c1/c.go -- +package c + +-- c2/go.mod -- +module example.com/c + +go 1.17 +-- c2/c.go -- +package c + +-- d/go.mod -- +module example.com/d + +go 1.17 diff --git a/src/cmd/go/testdata/script/mod_get_issue56494.txt b/src/cmd/go/testdata/script/mod_get_issue56494.txt index dabe23b9a7..3e4d4af834 100644 --- a/src/cmd/go/testdata/script/mod_get_issue56494.txt +++ b/src/cmd/go/testdata/script/mod_get_issue56494.txt @@ -35,9 +35,7 @@ # so 'go get' should prune it out too, and c should remain at c1 # without error. - # TODO(#56494): This should succeed, not error out. -! go get a@v0.3.0 -stderr 'INTERNAL ERROR' +go get a@v0.3.0 go list -m c stdout '^c v0.1.0 ' diff --git a/src/cmd/go/testdata/script/mod_get_newcycle.txt b/src/cmd/go/testdata/script/mod_get_newcycle.txt index 18dc650361..4f5229e57e 100644 --- a/src/cmd/go/testdata/script/mod_get_newcycle.txt +++ b/src/cmd/go/testdata/script/mod_get_newcycle.txt @@ -11,4 +11,4 @@ go mod init m cmp stderr stderr-expected -- stderr-expected -- -go: example.com/newcycle/a@v1.0.0 requires example.com/newcycle/a@v1.0.1, not example.com/newcycle/a@v1.0.0 +go: example.com/newcycle/a@v1.0.0 indirectly requires example.com/newcycle/a@v1.0.1, not example.com/newcycle/a@v1.0.0 diff --git a/src/cmd/go/testdata/script/mod_get_patchcycle.txt b/src/cmd/go/testdata/script/mod_get_patchcycle.txt index 6600109d2d..9f180d6b95 100644 --- a/src/cmd/go/testdata/script/mod_get_patchcycle.txt +++ b/src/cmd/go/testdata/script/mod_get_patchcycle.txt @@ -6,7 +6,7 @@ # (It used to print v0.1.1 but then silently upgrade to v0.2.0.) ! go get example.net/a@patch -stderr '^go: example.net/a@patch \(v0.1.1\) requires example.net/a@v0.2.0, not example.net/a@patch \(v0.1.1\)$' # TODO: A mention of b v0.1.0 would be nice. +stderr '^go: example.net/a@patch \(v0.1.1\) indirectly requires example.net/a@v0.2.0, not example.net/a@patch \(v0.1.1\)$' # TODO: A mention of b v0.1.0 would be nice. -- go.mod -- module example diff --git a/src/cmd/go/testdata/script/mod_install_pkg_version.txt b/src/cmd/go/testdata/script/mod_install_pkg_version.txt index 53c3e4134b..712375a6f8 100644 --- a/src/cmd/go/testdata/script/mod_install_pkg_version.txt +++ b/src/cmd/go/testdata/script/mod_install_pkg_version.txt @@ -160,7 +160,7 @@ cmp stderr exclude-err # 'go install pkg@version' should report an error if the module requires a # higher version of itself. ! go install example.com/cmd/a@v1.0.0-newerself -stderr '^go: example.com/cmd/a@v1.0.0-newerself: version constraints conflict:\n\texample.com/cmd@v1.0.0-newerself requires example.com/cmd@v1.0.0, but example.com/cmd@v1.0.0-newerself is requested$' +stderr '^go: example.com/cmd/a@v1.0.0-newerself: version constraints conflict:\n\texample.com/cmd@v1.0.0-newerself requires example.com/cmd@v1.0.0, but v1.0.0-newerself is requested$' # 'go install pkg@version' will only match a retracted version if it's diff --git a/src/cmd/go/testdata/script/mod_load_badchain.txt b/src/cmd/go/testdata/script/mod_load_badchain.txt index be2a4bc1db..500a954f5b 100644 --- a/src/cmd/go/testdata/script/mod_load_badchain.txt +++ b/src/cmd/go/testdata/script/mod_load_badchain.txt @@ -16,11 +16,12 @@ cmp go.mod go.mod.orig # Try to update the main module. This updates everything, including # modules that aren't direct requirements, so the error stack is shorter. -! go get -u ./... +go get -u ./... cmp stderr update-main-expected -cmp go.mod go.mod.orig +cmp go.mod go.mod.withc # Update manually. Listing modules should produce an error. +cp go.mod.orig go.mod go mod edit -require=example.com/badchain/a@v1.1.0 ! go list -m all cmp stderr list-expected @@ -40,6 +41,15 @@ module m go 1.13 require example.com/badchain/a v1.0.0 +-- go.mod.withc -- +module m + +go 1.13 + +require ( + example.com/badchain/a v1.0.0 + example.com/badchain/c v1.0.0 +) -- go.sum -- example.com/badchain/a v1.0.0 h1:iJDLiHLmpQgr9Zrv+44UqywAE2IG6WkHnH4uG08vf+s= example.com/badchain/a v1.0.0/go.mod h1:6/gnCYHdVrs6mUgatUYUSbuHxEY+/yWedmTggLz23EI= @@ -72,10 +82,9 @@ func Test(t *testing.T) {} go: example.com/badchain/c@v1.1.0: parsing go.mod: module declares its path as: badchain.example.com/c but was required as: example.com/badchain/c + restoring example.com/badchain/c@v1.0.0 -- update-a-expected -- -go: example.com/badchain/a@v1.1.0 requires - example.com/badchain/b@v1.1.0 requires - example.com/badchain/c@v1.1.0: parsing go.mod: +go: example.com/badchain/a@upgrade (v1.1.0) indirectly requires example.com/badchain/c@v1.1.0: parsing go.mod: module declares its path as: badchain.example.com/c but was required as: example.com/badchain/c -- list-expected -- |