mirror of
https://github.com/golang/go.git
synced 2025-05-28 10:51:22 +00:00
cmd/go: add a test that reproduces an unstable 'go mod tidy'
For #60313. Change-Id: I76e48f52341e9962de9b809741a677d61baae6a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/496518 Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
5abfdc8c75
commit
53e0616c13
76
src/cmd/go/testdata/script/mod_tidy_issue60313.txt
vendored
Normal file
76
src/cmd/go/testdata/script/mod_tidy_issue60313.txt
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
# Regression test for https://go.dev/issue/60313: 'go mod tidy' did not preserve
|
||||
# dependencies needed to prevent 'ambiguous import' errors in external test
|
||||
# dependencies.
|
||||
|
||||
go mod tidy
|
||||
cp go.mod tidy1.mod
|
||||
|
||||
! go mod tidy # BUG: This should succeed and leave go.mod unchanged.
|
||||
# cmp go.mod tidy1.mod
|
||||
stderr 'ambiguous import'
|
||||
|
||||
-- go.mod --
|
||||
module example
|
||||
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
example.net/a v0.1.0
|
||||
example.net/b v0.1.0
|
||||
)
|
||||
|
||||
require example.net/outer/inner v0.1.0 // indirect
|
||||
|
||||
replace (
|
||||
example.net/a v0.1.0 => ./a
|
||||
example.net/b v0.1.0 => ./b
|
||||
example.net/outer v0.1.0 => ./outer1
|
||||
example.net/outer/inner v0.1.0 => ./inner
|
||||
)
|
||||
-- example.go --
|
||||
package example
|
||||
|
||||
import (
|
||||
_ "example.net/a"
|
||||
_ "example.net/b"
|
||||
)
|
||||
-- a/go.mod --
|
||||
module example.net/a
|
||||
|
||||
go 1.21
|
||||
|
||||
require example.net/outer/inner v0.1.0
|
||||
-- a/a.go --
|
||||
package a
|
||||
-- a/a_test.go --
|
||||
package a_test
|
||||
|
||||
import _ "example.net/outer/inner"
|
||||
-- b/go.mod --
|
||||
module example.net/b
|
||||
|
||||
go 1.21
|
||||
|
||||
require example.net/outer v0.1.0
|
||||
-- b/b.go --
|
||||
package b
|
||||
-- b/b_test.go --
|
||||
package b_test
|
||||
|
||||
import _ "example.net/outer/inner"
|
||||
-- inner/go.mod --
|
||||
module example.net/outer/inner
|
||||
|
||||
go 1.21
|
||||
-- inner/inner.go --
|
||||
package inner
|
||||
-- outer1/go.mod --
|
||||
module example.net/outer
|
||||
|
||||
go 1.21
|
||||
-- outer1/inner/inner.go --
|
||||
package inner
|
||||
-- outer2/go.mod --
|
||||
module example.net/outer
|
||||
|
||||
go 1.21
|
Loading…
x
Reference in New Issue
Block a user