Skip to content

Commit

Permalink
cmd/updatestd: skip TestBuildList in short mode
Browse files Browse the repository at this point in the history
The 'go list -m all' command may use the internet if the module cache
is incomplete. (It wouldn't do that if -mod=vendor were chosen either
explicitly or implicitly, but that's not the case here as buildList
uses -mod=readonly and thus ignores the vendor directory.)

Since 'go test -short' is not expected to require internet access,
test buildList only when -short is false.

This was found by the new no-network check being implemented in LUCI.
It wasn't reported by the no-network check in x/build because its
implementation doesn't block internet access to $(go env GOPROXY).

Change-Id: I62db17af35f9d734deb9027b6bedfa45f84a0954
Reviewed-on: https://go-review.googlesource.com/c/build/+/507475
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
dmitshur authored and gopherbot committed Jul 6, 2023
1 parent e764d3a commit 2312c11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/updatestd/updatestd.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ func (w Work) UpdateModule(dir string) error {
// It returns the main module and other modules separately
// for convenience to the UpdateModule caller.
//
// See https://golang.org/cmd/go/#hdr-The_main_module_and_the_build_list
// and https://golang.org/ref/mod#glos-build-list.
// See https://go.dev/ref/mod#go-list-m and https://go.dev/ref/mod#glos-build-list.
func buildList(dir string) (main module, deps []module) {
out := runner{dir}.runOut(goCmd, "list", "-mod=readonly", "-m", "-json", "all")
for dec := json.NewDecoder(bytes.NewReader(out)); ; {
Expand Down
4 changes: 4 additions & 0 deletions cmd/updatestd/updatestd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
)

func TestBuildList(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode because buildList may need to use the internet")
}

goCmd = "go" // for testing, using the go command in PATH
gowork := strings.TrimSpace(string(runner{"."}.runOut("go", "env", "GOWORK")))
if gowork != "" && gowork != "off" {
Expand Down

0 comments on commit 2312c11

Please sign in to comment.