mirror of
https://github.com/golang/go
synced 2024-11-17 12:14:47 -07:00
cmd/go: add script tests for potential upgrades due to downgrades
For #36460 Change-Id: I1620c23819263ef82e571fc4d4c778277842c02d Reviewed-on: https://go-review.googlesource.com/c/go/+/288535 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
a5c8a15f64
commit
f3c2208e2c
81
src/cmd/go/testdata/script/mod_get_downadd_indirect.txt
vendored
Normal file
81
src/cmd/go/testdata/script/mod_get_downadd_indirect.txt
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# This test illustrates a case where downgrading one module may upgrade another.
|
||||||
|
# Compare to the downcross2 test case in cmd/go/internal/mvs/mvs_test.go.
|
||||||
|
|
||||||
|
# The initial package import graph used in this test looks like:
|
||||||
|
#
|
||||||
|
# a ---- b ---- d
|
||||||
|
#
|
||||||
|
# The module dependency graph originally looks like:
|
||||||
|
#
|
||||||
|
# a ---- b.2 ---- d.2
|
||||||
|
#
|
||||||
|
# b.1 ---- c.1
|
||||||
|
#
|
||||||
|
# If we downgrade module d to version 1, we must downgrade b as well.
|
||||||
|
# If that downgrade selects b version 1, we will add a new dependency on module c.
|
||||||
|
|
||||||
|
cp go.mod go.mod.orig
|
||||||
|
go mod tidy
|
||||||
|
cmp go.mod.orig go.mod
|
||||||
|
|
||||||
|
go get -d example.com/d@v0.1.0
|
||||||
|
go list -m all
|
||||||
|
stdout '^example.com/b v0.1.0 '
|
||||||
|
stdout '^example.com/c v0.1.0 '
|
||||||
|
stdout '^example.com/d v0.1.0 '
|
||||||
|
|
||||||
|
-- go.mod --
|
||||||
|
module example.com/a
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
require example.com/b v0.2.0
|
||||||
|
|
||||||
|
replace (
|
||||||
|
example.com/b v0.1.0 => ./b1
|
||||||
|
example.com/b v0.2.0 => ./b2
|
||||||
|
example.com/c v0.1.0 => ./c
|
||||||
|
example.com/d v0.1.0 => ./d
|
||||||
|
example.com/d v0.2.0 => ./d
|
||||||
|
)
|
||||||
|
-- a.go --
|
||||||
|
package a
|
||||||
|
|
||||||
|
import _ "example.com/b"
|
||||||
|
|
||||||
|
-- b1/go.mod --
|
||||||
|
module example.com/b
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
require example.com/c v0.1.0
|
||||||
|
-- b1/b.go --
|
||||||
|
package b
|
||||||
|
|
||||||
|
import _ "example.com/c"
|
||||||
|
|
||||||
|
-- b2/go.mod --
|
||||||
|
module example.com/b
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
require example.com/d v0.2.0
|
||||||
|
-- b2/b.go --
|
||||||
|
package b
|
||||||
|
|
||||||
|
import _ "example.com/d"
|
||||||
|
|
||||||
|
-- c/go.mod --
|
||||||
|
module example.com/c
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
-- c/c.go --
|
||||||
|
package c
|
||||||
|
|
||||||
|
-- d/go.mod --
|
||||||
|
module example.com/d
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
-- d/d.go --
|
||||||
|
package d
|
101
src/cmd/go/testdata/script/mod_get_downup_indirect.txt
vendored
Normal file
101
src/cmd/go/testdata/script/mod_get_downup_indirect.txt
vendored
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
# This test illustrates a case where downgrading one module may upgrade another.
|
||||||
|
# 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.
|
||||||
|
# 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
|
||||||
|
|
||||||
|
go get -d example.com/d@v0.1.0
|
||||||
|
go list -m all
|
||||||
|
! stdout '^example.com/b '
|
||||||
|
! stdout '^example.com/c '
|
||||||
|
stdout '^example.com/d v0.1.0 '
|
||||||
|
|
||||||
|
-- go.mod --
|
||||||
|
module example.com/a
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
-- a.go --
|
||||||
|
package a
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "example.com/b"
|
||||||
|
_ "example.com/c"
|
||||||
|
)
|
||||||
|
|
||||||
|
-- b1/go.mod --
|
||||||
|
module example.com/b
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
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.15
|
||||||
|
|
||||||
|
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.15
|
||||||
|
|
||||||
|
require example.com/d v0.2.0
|
||||||
|
-- c1/c.go --
|
||||||
|
package c
|
||||||
|
|
||||||
|
-- c2/go.mod --
|
||||||
|
module example.com/c
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
-- c2/c.go --
|
||||||
|
package c
|
||||||
|
|
||||||
|
-- d/go.mod --
|
||||||
|
module example.com/d
|
||||||
|
|
||||||
|
go 1.15
|
Loading…
Reference in New Issue
Block a user