From e020be094791938736f7312408e8d1b044783d3c Mon Sep 17 00:00:00 2001 From: Joe Fitzgerald Date: Fri, 12 Jan 2024 09:36:31 -0700 Subject: [PATCH] update ci.sh to make it easier to test prerelease versions of go also remove unnecessary integration test logic for GO111MODULE and GOPATH Signed-off-by: Joe Fitzgerald --- integration/roundtrip_test.go | 33 +++++++-------------------------- scripts/ci.sh | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/integration/roundtrip_test.go b/integration/roundtrip_test.go index 55840d0..45939f3 100644 --- a/integration/roundtrip_test.go +++ b/integration/roundtrip_test.go @@ -2,7 +2,6 @@ package integration_test import ( "fmt" - "go/build" "io" "log" "os" @@ -20,26 +19,19 @@ func runTests(t *testing.T, when spec.G, it spec.S) { log.SetOutput(io.Discard) // Comment this out to see verbose log output log.SetFlags(log.Llongfile) var ( - baseDir string - relativeDir string - originalGopath string - originalBuildGopath string - originalGo111module string - testDir string - copyDirFunc func() - copyFileFunc func(name string) - initModuleFunc func() - writeToTestData bool + baseDir string + relativeDir string + testDir string + copyDirFunc func() + copyFileFunc func(name string) + initModuleFunc func() + writeToTestData bool ) name := "working with a module" it.Before(func() { RegisterTestingT(t) - originalGo111module = os.Getenv("GO111MODULE") - os.Setenv("GO111MODULE", "on") - originalGopath = os.Getenv("GOPATH") - originalBuildGopath = build.Default.GOPATH var err error testDir, err = os.MkdirTemp("", "counterfeiter-integration") Expect(err).NotTo(HaveOccurred()) @@ -79,17 +71,6 @@ func runTests(t *testing.T, when spec.G, it spec.S) { }) it.After(func() { - if originalGo111module != "" { - os.Setenv("GO111MODULE", originalGo111module) - } else { - os.Unsetenv("GO111MODULE") - } - if originalGopath != "" { - os.Setenv("GOPATH", originalGopath) - } else { - os.Unsetenv("GOPATH") - } - build.Default.GOPATH = originalBuildGopath if baseDir == "" { return } diff --git a/scripts/ci.sh b/scripts/ci.sh index 0662cea..cf8970c 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -5,23 +5,26 @@ set -eu cd "$(dirname "$0")/.." pwd -# run go vet to verify everything builds and to check common issues +GOCOMMAND="go" +# GOCOMMAND="go1.22rc1" + +# run ${GOCOMMAND} vet to verify everything builds and to check common issues echo -echo "Running go vet..." +echo "Running ${GOCOMMAND} vet..." echo -GO111MODULE=on go vet ./... +${GOCOMMAND} vet ./... # counterfeit all the things echo echo "Installing counterfeiter..." echo -GO111MODULE=on go install . +${GOCOMMAND} install . # counterfeit all the things echo echo "Generating fakes used by tests..." echo -GO111MODULE=on go generate ./... +${GOCOMMAND} generate ./... # validate that the generated fakes match the committed fakes echo @@ -29,7 +32,7 @@ echo "Validating that generated fakes have not changed..." echo git diff --exit-code if output=$(git status --porcelain) && [ ! -z "$output" ]; then - echo "the working copy is not clean; make sure that go generate ./... has been run, and" + echo "the working copy is not clean; make sure that ${GOCOMMAND} generate ./... has been run, and" echo "that you have committed or ignored all files before running ./scripts/ci.sh" exit 1 fi @@ -38,13 +41,13 @@ fi echo echo "Ensuring generated fakes compile..." echo -GO111MODULE=on go build -v ./... +${GOCOMMAND} build -v ./... # run the tests using the fakes echo echo "Running tests..." echo -GO111MODULE=on go test -race ./... +${GOCOMMAND} test -race ./... echo " _______ _ _ _______ _______ _______