From fa40c0232c79f1e8eb6bda6c63604958bdf1102f Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Mon, 22 Feb 2021 15:04:25 -0500 Subject: [PATCH] cmd/go: reproduce issue #44497 in TestScript/mod_edit For #44497 Change-Id: Ie5285b9c526506b6b1280a590a5dcbee4074f57b Reviewed-on: https://go-review.googlesource.com/c/go/+/295149 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Jay Conrod --- src/cmd/go/testdata/script/mod_edit.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/cmd/go/testdata/script/mod_edit.txt b/src/cmd/go/testdata/script/mod_edit.txt index d7e681e8313..02d2d40bbb4 100644 --- a/src/cmd/go/testdata/script/mod_edit.txt +++ b/src/cmd/go/testdata/script/mod_edit.txt @@ -26,6 +26,25 @@ cmpenv go.mod $WORK/go.mod.edit2 stderr '^go mod: -exclude=example.com/m@bad: version "bad" invalid: must be of the form v1.2.3$' ! go mod edit -retract=bad stderr '^go mod: -retract=bad: version "bad" invalid: must be of the form v1.2.3$' +cmpenv go.mod $WORK/go.mod.edit2 + +cp go.mod go.mod.beforebugs + +# BUG(#44497): -exclude accepts a mismatched major version without +incompatible, but should not. +go mod edit -exclude=example.com/m@v2.0.0 +! go mod edit -json +stderr '^go: errors parsing go.mod:\n.*[/\\]go.mod:16: exclude example\.com/m: version "v2\.0\.0" invalid: should be v0 or v1, not v2$' +cp go.mod.beforebugs go.mod + +# BUG(#44497): -exclude accepts a v1 version for a v2 module, but should not. +go mod edit -exclude=example.com/m/v2@v1.0.0 +! go mod edit -json +stderr '^go: errors parsing go.mod:\n.*[/\\]go.mod:16: exclude example\.com/m/v2: version "v1\.0\.0" invalid: should be v2, not v1$' +cp go.mod.beforebugs go.mod + +# BUG(#44497): -exclude rejects a +incompatible version for an unversioned +# module path, but should not. +! go mod edit -exclude=example.com/m@v2.0.0+incompatible # go mod edit -json go mod edit -json