Description
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