From: Michael Matloob Date: Mon, 28 Feb 2022 21:39:28 +0000 (-0500) Subject: cmd/go: make work and work_edit script tests version-independent X-Git-Tag: go1.18~33^2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=acc5f55bac6884f8b27c5b73c4a15d777a7169a0;p=gostls13.git cmd/go: make work and work_edit script tests version-independent The work and work_edit script tests ran go work init, which put the current Go version into the go.work files. Before this change, the tests used cmp to compare the outputs with a file that contained a literal "go 1.18" line. Instead, use cmpenv so we can compare with "go $goversion". (Some of the test cases still compare against files that contain "go 1.18" lines, but these tests explicitly set the version to go 1.18 either in the original go.work files or using go work edit.) Change-Id: Iea2caa7697b5fe5939070558b1664f70130095ce Reviewed-on: https://go-review.googlesource.com/c/go/+/388514 Trust: Michael Matloob Run-TryBot: Michael Matloob Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Carlos Amedee --- diff --git a/src/cmd/go/testdata/script/work.txt b/src/cmd/go/testdata/script/work.txt index a10bf5a1c3..fa1558f9e6 100644 --- a/src/cmd/go/testdata/script/work.txt +++ b/src/cmd/go/testdata/script/work.txt @@ -4,7 +4,7 @@ go env GOWORK ! stdout . go work init ./a ./b -cmp go.work go.work.want +cmpenv go.work go.work.want go env GOWORK stdout '^'$WORK'(\\|/)gopath(\\|/)src(\\|/)go.work$' @@ -69,7 +69,7 @@ use ( ../src/a ) -- go.work.want -- -go 1.18 +go $goversion use ( ./a diff --git a/src/cmd/go/testdata/script/work_edit.txt b/src/cmd/go/testdata/script/work_edit.txt index 71959ca0dd..278afb7f61 100644 --- a/src/cmd/go/testdata/script/work_edit.txt +++ b/src/cmd/go/testdata/script/work_edit.txt @@ -1,10 +1,10 @@ # Test editing go.work files. go work init m -cmp go.work go.work.want_initial +cmpenv go.work go.work.want_initial go work edit -use n -cmp go.work go.work.want_use_n +cmpenv go.work go.work.want_use_n go work edit -go 1.18 cmp go.work go.work.want_go_118 @@ -39,11 +39,11 @@ module m go 1.18 -- go.work.want_initial -- -go 1.18 +go $goversion use ./m -- go.work.want_use_n -- -go 1.18 +go $goversion use ( ./m