Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/refactor/importgraph: running tests with GO111MODULE=on is slow and writes to GOPATH workspace #30221

Open
dmitshur opened this Issue Feb 14, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@dmitshur
Copy link
Member

dmitshur commented Feb 14, 2019

Can be reproduced using Go 1.11.5 on macOS:

$ ls /tmp/gopath
ls: /tmp/gopath: No such file or directory
$ export GOPATH=/tmp/gopath
$ go get github.com/shurcooL/github_flavored_markdown
$ go get golang.org/x/tools/refactor/importgraph
$ shasum /tmp/gopath/src/github.com/shurcooL/github_flavored_markdown/go.mod
965892713fd48f7842527e54e9a8d63639d8afe4  /tmp/gopath/src/github.com/shurcooL/github_flavored_markdown/go.mod
$ cd /tmp/gopath/src/golang.org/x/tools/refactor/importgraph

importgraph $ GO111MODULE=off go test -count=1
PASS
ok  	golang.org/x/tools/refactor/importgraph	0.337s
importgraph $ shasum /tmp/gopath/src/github.com/shurcooL/github_flavored_markdown/go.mod
965892713fd48f7842527e54e9a8d63639d8afe4  /tmp/gopath/src/github.com/shurcooL/github_flavored_markdown/go.mod

importgraph $ GO111MODULE=on go test -count=1
go: creating new go.mod: module golang.org/x/tools
PASS
ok  	golang.org/x/tools/refactor/importgraph	25.369s
importgraph $ shasum /tmp/gopath/src/github.com/shurcooL/github_flavored_markdown/go.mod
3bf82fbc8cf4b6b2366a5d87ab990a94af8bc1e4  /tmp/gopath/src/github.com/shurcooL/github_flavored_markdown/go.mod

Running importgraph tests in module mode should not make modifications inside the user's GOPATH workspace. Fortunately, it only modifies go.mod and go.sum files, which is easy to revert thanks to version control systems.

It also makes the test very slow when one's GOPATH is sizable. With my real GOPATH, it was:

tools $ GO111MODULE=off go test -short -count=1 ./refactor/importgraph
ok  	golang.org/x/tools/refactor/importgraph	1.110s
tools $ GO111MODULE=on go test -short -count=1 ./refactor/importgraph
ok  	golang.org/x/tools/refactor/importgraph	283.044s

/cc @ianthehat @matloob

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.