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

cmd/go: in tests, populate go.sum files and reduce usage of -mod=mod #41302

jayconrod opened this issue Sep 9, 2020 · 1 comment

cmd/go: in tests, populate go.sum files and reduce usage of -mod=mod #41302

jayconrod opened this issue Sep 9, 2020 · 1 comment


Copy link

@jayconrod jayconrod commented Sep 9, 2020

This issue acts as a TODO for a number of comments raised in review of CL 251881, which enables -mod=readonly by default for #40278. Two broad issues should be fixed in the cmd/go integration tests.

First, -mod=mod is used in a lot of places with go list or go build. We should make the tests follow more idiomatic usage. If something is missing from go.mod or go.sum, we should run go get -d, go mod tidy, or go mod download first. The following tests need changes. There are probably more.

  • mod_doc
  • mod_download.
  • mod_invalid_version
  • mod_list
  • mod_load_badzip
  • mod_replace
  • mod_replace_gopkgin
  • mod_require_exclude
  • mod_sumdb_golang

Second, many tests fail without -mod=mod because the test archive doesn't include a go.sum file. I'd rather not include literal go.sum files in tests, since they'll make tests more difficult to write and act as change detectors. Instead, we should have a command or sequence of commands run at the beginning of a test that fills in missing sums without modifying go.mod. Something like:

cp go.mod go.mod.orig
go get -d ./...
cmp go.mod go.mod.orig

If this turns out to be too repetitive, we may want to add a script_test.go command to shorten it.

The following tests need changes. Again, there are probably more.

  • mod_list_dir
  • mod_list_replace_dir
  • mod_list_upgrade
  • mod_load_badmod
  • mod_modinfo
@jayconrod jayconrod added this to the Go1.16 milestone Sep 9, 2020
@jayconrod jayconrod self-assigned this Sep 9, 2020
Copy link
Contributor Author

@jayconrod jayconrod commented Sep 10, 2020

Also, mod_missingpkg_prerelease. go get -d should report errors on transitively imported packages.

@jayconrod jayconrod modified the milestones: Go1.16, Go1.17 Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant