Keep temporary module caches removable by non-root tests
Private module tooling / contract (pull_request) Successful in 55s

This commit is contained in:
Donavan Fritz committed 2026-11-13 22:49:58 -06:00
1 parent 49979f30e4
commit 6a0e073ed3
1 file changed
+3 -1
+3 -1
View File
@@ -106,10 +106,12 @@ func TestNativeGoSumRejectsChangedModuleArtifact(t *testing.T) {
}
mustFixture(t, os.WriteFile(base+".zip", archive.Bytes(), 0600))
mustFixture(t, os.WriteFile(filepath.Join(root, "go.mod"), []byte("module example.invalid/checksum\n\ngo 1.27.0\n\nrequire "+modulePath+" "+version+"\n"), 0600))
// Keep this isolated fixture cache removable by a non-root test process.
// Module content checksum validation is unchanged.
run := func(cache string) ([]byte, error) {
cmd := exec.Command("go", "mod", "download", modulePath+"@"+version)
cmd.Dir = root
cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOMODCACHE="+filepath.Join(root, cache), "GOPROXY=file://"+proxy, "GONOPROXY=none", "GONOSUMDB="+privatePrefix, "GOSUMDB=off", "GOTOOLCHAIN=local", "GOFLAGS=", "GOWORK=off")
cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOMODCACHE="+filepath.Join(root, cache), "GOPROXY=file://"+proxy, "GONOPROXY=none", "GONOSUMDB="+privatePrefix, "GOSUMDB=off", "GOTOOLCHAIN=local", "GOFLAGS=-modcacherw", "GOWORK=off")
return cmd.CombinedOutput()
}
if output, err := run("original-cache"); err != nil {