From 16cebc1165d0613051bb5ae97e1af856f8bc55f2 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Sun, 8 Mar 2026 15:46:36 -0400 Subject: [PATCH] cmd/go/testdata/script: update more tests to not use network For these tests, I've been able to use modules that are in the local proxy and vcstest server (or add modules to them where modules didn't already exist) to exercise the tested functionality of the go command. This should help make our longtests run faster and be less flaky. This CL also removes lines in the tests that set GO111MODULE=on since that's now the default. Change-Id: Ie0b2c905850f84100213e1ab35ec2a226a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/753140 Reviewed-by: Dmitri Shuralyov Reviewed-by: Ian Alexander LUCI-TryBot-Result: Go LUCI Auto-Submit: Michael Matloob Reviewed-by: Dmitri Shuralyov Reviewed-by: Michael Matloob Auto-Submit: Michael Matloob --- ...git_v0.0.0-20170922010558-fc3a09f3dc5c.txt | 13 ++++++++ src/cmd/go/testdata/script/get_insecure.txt | 20 ++++++------ .../go/testdata/script/mod_download_hash.txt | 20 ++++++------ .../go/testdata/script/mod_get_fallback.txt | 15 ++++----- src/cmd/go/testdata/script/mod_get_hash.txt | 11 +++---- src/cmd/go/testdata/script/mod_getx.txt | 9 +++--- .../go/testdata/script/mod_vcs_missing.txt | 7 ++--- .../testdata/vcstest/git/unreachable-hash.txt | 31 +++++++++++++++++++ 8 files changed, 81 insertions(+), 45 deletions(-) create mode 100644 src/cmd/go/testdata/mod/vcs-test.golang.org_git_hello.git_v0.0.0-20170922010558-fc3a09f3dc5c.txt create mode 100644 src/cmd/go/testdata/vcstest/git/unreachable-hash.txt diff --git a/src/cmd/go/testdata/mod/vcs-test.golang.org_git_hello.git_v0.0.0-20170922010558-fc3a09f3dc5c.txt b/src/cmd/go/testdata/mod/vcs-test.golang.org_git_hello.git_v0.0.0-20170922010558-fc3a09f3dc5c.txt new file mode 100644 index 0000000000..80881a0b81 --- /dev/null +++ b/src/cmd/go/testdata/mod/vcs-test.golang.org_git_hello.git_v0.0.0-20170922010558-fc3a09f3dc5c.txt @@ -0,0 +1,13 @@ +written by hand + +-- .mod -- +module vcs-test.golang.org/git/hello.git +-- .info -- +{"Version":"v0.0.0-20170922010558-fc3a09f3dc5c"} +-- testonly.go -- +package main + +func main() { + println("hello, world") +} + diff --git a/src/cmd/go/testdata/script/get_insecure.txt b/src/cmd/go/testdata/script/get_insecure.txt index f29ec2daed..0a2438038f 100644 --- a/src/cmd/go/testdata/script/get_insecure.txt +++ b/src/cmd/go/testdata/script/get_insecure.txt @@ -1,4 +1,5 @@ -[!net:insecure.go-get-issue-15410.appspot.com] skip +# Test for #15410 +[short] skip 'builds a go program and a git repo' [!git] skip env PATH=$WORK/tmp/bin${:}$PATH @@ -9,24 +10,23 @@ env GOPATH=$WORK/m/gp mkdir $WORK/m cp module_file $WORK/m/go.mod cd $WORK/m -env GO111MODULE=on -env GOPROXY='' +env GOPROXY=${GOPROXY},direct -# Modules: Try go get -d of HTTP-only repo (should fail). -! go get -d insecure.go-get-issue-15410.appspot.com/pkg/p +# Modules: Try go get of HTTP-only repo (should fail). +! go get -d vcs-test.golang.org/insecure/go/insecure@6fecd21 # Modules: Try again with GOINSECURE (should succeed). -env GOINSECURE=insecure.go-get-issue-15410.appspot.com -env GONOSUMDB=insecure.go-get-issue-15410.appspot.com -go get -d insecure.go-get-issue-15410.appspot.com/pkg/p +env GOINSECURE=vcs-test.golang.org/insecure/go/insecure +env GONOSUMDB=vcs-test.golang.org/insecure +go get -d vcs-test.golang.org/insecure/go/insecure@6fecd21 # Modules: Try updating without GOINSECURE (should fail). env GOINSECURE='' env GONOSUMDB='' -! go get -d -u -f insecure.go-get-issue-15410.appspot.com/pkg/p +! go get -d -u -f vcs-test.golang.org/insecure/go/insecure@6fecd21 go list -m ... -stdout 'insecure.go-get-issue' +stdout 'vcs-test.golang.org/insecure/go/insecure' -- ssh.go -- // stub out uses of ssh by go get diff --git a/src/cmd/go/testdata/script/mod_download_hash.txt b/src/cmd/go/testdata/script/mod_download_hash.txt index 5677e69a5d..e23cb63606 100644 --- a/src/cmd/go/testdata/script/mod_download_hash.txt +++ b/src/cmd/go/testdata/script/mod_download_hash.txt @@ -1,20 +1,18 @@ -env GO111MODULE=on - # Testing mod download with non semantic versions; turn off proxy. -[!net:rsc.io] skip +[short] skip [!git] skip env GOPROXY=direct env GOSUMDB=off -go mod download rsc.io/quote@a91498bed0a73d4bb9c1fb2597925f7883bc40a7 -exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.3-0.20180709162918-a91498bed0a7.info -exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.3-0.20180709162918-a91498bed0a7.mod -exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.3-0.20180709162918-a91498bed0a7.zip +go mod download vcs-test.golang.org/git/hello.git@fc3a09f +exists $GOPATH/pkg/mod/cache/download/vcs-test.golang.org/git/hello.git/@v/v0.0.0-20170922010558-fc3a09f3dc5c.info +exists $GOPATH/pkg/mod/cache/download/vcs-test.golang.org/git/hello.git/@v/v0.0.0-20170922010558-fc3a09f3dc5c.mod +exists $GOPATH/pkg/mod/cache/download/vcs-test.golang.org/git/hello.git/@v/v0.0.0-20170922010558-fc3a09f3dc5c.zip -go mod download rsc.io/quote@master -exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.3-0.20180709162918-a91498bed0a7.info -exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.3-0.20180709162918-a91498bed0a7.mod -exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.3-0.20180709162918-a91498bed0a7.zip +go mod download vcs-test.golang.org/git/hello.git@master +exists $GOPATH/pkg/mod/cache/download/vcs-test.golang.org/git/hello.git/@v/v0.0.0-20170922010558-fc3a09f3dc5c.info +exists $GOPATH/pkg/mod/cache/download/vcs-test.golang.org/git/hello.git/@v/v0.0.0-20170922010558-fc3a09f3dc5c.mod +exists $GOPATH/pkg/mod/cache/download/vcs-test.golang.org/git/hello.git/@v/v0.0.0-20170922010558-fc3a09f3dc5c.zip -- go.mod -- diff --git a/src/cmd/go/testdata/script/mod_get_fallback.txt b/src/cmd/go/testdata/script/mod_get_fallback.txt index a5119b6efe..794a46e2fa 100644 --- a/src/cmd/go/testdata/script/mod_get_fallback.txt +++ b/src/cmd/go/testdata/script/mod_get_fallback.txt @@ -1,14 +1,11 @@ -env GO111MODULE=on - -[!net:golang.org] skip -[!net:proxy.golang.org] skip - -env GOPROXY=https://proxy.golang.org,direct env GOSUMDB=off -go get -x -v golang.org/x/tools/cmd/goimports -stderr '# get https://proxy.golang.org/golang.org/x/tools/@v/list' -! stderr '# get https://golang.org' +env LOCALMODPROXY=$GOPROXY +env GOPROXY=$LOCALMODPROXY,direct + +go get -x -v vcs-test.golang.org/git/hello.git +stderr '# get '$LOCALMODPROXY'/vcs-test.golang.org/git/hello.git/@v/list' +! stderr '# get https://vcs-test.golang.org' -- go.mod -- module m diff --git a/src/cmd/go/testdata/script/mod_get_hash.txt b/src/cmd/go/testdata/script/mod_get_hash.txt index ec5549defe..eb8e7bdfb6 100644 --- a/src/cmd/go/testdata/script/mod_get_hash.txt +++ b/src/cmd/go/testdata/script/mod_get_hash.txt @@ -1,18 +1,17 @@ -env GO111MODULE=on env GOPROXY=direct env GOSUMDB=off -[!net:golang.org] skip +[short] skip [!git] skip # fetch commit hash reachable from refs/heads/* and refs/tags/* is OK -go list -m golang.org/x/time@8be79e1e0910c292df4e79c241bb7e8f7e725959 # on master branch +go list -m vcs-test.golang.org/git/unreachable-hash.git@6c0e37b1dcaab081b5c413108a46669027fcf02b # on main branch # fetch other commit hash, even with a non-standard ref, is not OK -! go list -m golang.org/x/time@334d83c35137ac2b376c1dc3e4c7733791855a3a # refs/changes/24/41624/3 +! go list -m vcs-test.golang.org/git/unreachable-hash.git@cbd2996c52d20dac558bc3b49c342c7c8320a1fc stderr 'unknown revision' -! go list -m golang.org/x/time@v0.0.0-20170424233410-334d83c35137 +! go list -m vcs-test.golang.org/git/unreachable-hash.git@v0.0.0-20170424233410-cbd2996c52d2 stderr 'unknown revision' -! go list -m golang.org/x/time@334d83c35137 +! go list -m vcs-test.golang.org/git/unreachable-hash.git@cbd2996c52d2 stderr 'unknown revision' -- go.mod -- diff --git a/src/cmd/go/testdata/script/mod_getx.txt b/src/cmd/go/testdata/script/mod_getx.txt index 46bb95bf58..8a70da1ad2 100644 --- a/src/cmd/go/testdata/script/mod_getx.txt +++ b/src/cmd/go/testdata/script/mod_getx.txt @@ -1,15 +1,14 @@ -[!net:golang.org] skip +[short] skip [!git] skip -env GO111MODULE=on env GOPROXY=direct env GOSUMDB=off # 'go get -x' should log URLs with an HTTP or HTTPS scheme. # A bug had caused us to log schemeless URLs instead. -go get -x golang.org/x/text@v0.1.0 -stderr '^# get https://golang.org/x/text\?go-get=1$' -stderr '^# get https://golang.org/x/text\?go-get=1: 200 OK \([0-9.]+s\)$' +go get -x vcs-test.golang.org/go/mod/gitrepo1@v1.2.3 +stderr '^# get https://vcs-test.golang.org/go/mod/gitrepo1\?go-get=1$' +stderr '^# get https://vcs-test.golang.org/go/mod/gitrepo1\?go-get=1: 200 OK \([0-9.]+s\)$' ! stderr '^# get //.*' -- go.mod -- diff --git a/src/cmd/go/testdata/script/mod_vcs_missing.txt b/src/cmd/go/testdata/script/mod_vcs_missing.txt index 7f63e9de21..1f218c8d95 100644 --- a/src/cmd/go/testdata/script/mod_vcs_missing.txt +++ b/src/cmd/go/testdata/script/mod_vcs_missing.txt @@ -1,11 +1,10 @@ [exec:bzr] skip 'tests NOT having bzr' -[!net:launchpad.net] skip +[short] skip -env GO111MODULE=on env GOPROXY=direct cd empty -! go get launchpad.net/gocheck +! go get vcs-test.golang.org/foo.bzr stderr '"bzr": executable file not found' cd .. @@ -23,6 +22,6 @@ module m -- main/main.go -- package main -import _ "launchpad.net/gocheck" +import _ "vcs-test.golang.org/foo.bzr" func main() {} diff --git a/src/cmd/go/testdata/vcstest/git/unreachable-hash.txt b/src/cmd/go/testdata/vcstest/git/unreachable-hash.txt new file mode 100644 index 0000000000..6a05be41df --- /dev/null +++ b/src/cmd/go/testdata/vcstest/git/unreachable-hash.txt @@ -0,0 +1,31 @@ +handle git + +env GIT_AUTHOR_NAME='Michael Matloob' +env GIT_AUTHOR_EMAIL='matloob@golang.org' +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL + +at 2017-04-24T23:34:10-00:00 + +git init +cp go.mod.orig go.mod +git add go.mod +git write-tree +git commit-tree 995c9bbddb810e9fe22d0ba73d661c599eec29e8 -m foo +git checkout cbd2996c52d20dac558bc3b49c342c7c8320a1fc + +git switch --orphan main +mv go.mod.orig go.mod +git add go.mod +git commit -m bar + +git log --oneline --decorate=short main cbd2996c52d20dac558bc3b49c342c7c8320a1fc +cmp stdout .git-log + +-- .git-log -- +6c0e37b (HEAD -> main) bar +cbd2996 foo +-- go.mod.orig -- +module vcs-test.golang.org/git/ureachable-hash.git + +go 1.26