Allow non-root cleanup of checksum test cache #3

Merged
dfritz merged 1 commits from fix/private-module-test-cleanup into main 2026-11-14 04:52:06 +00:00
Showing only changes of commit 6a0e073ed3 - Show all commits
+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 {