Allow non-root cleanup of checksum test cache (#3)
Private module tooling / contract (push) Successful in 57s

This commit was merged in pull request #3.
This commit is contained in:
dfritz committed 2026-11-14 04:52:05 +00:00
1 parent 49979f30e4
commit 59b36d7a3c
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(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)) 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) { run := func(cache string) ([]byte, error) {
cmd := exec.Command("go", "mod", "download", modulePath+"@"+version) cmd := exec.Command("go", "mod", "download", modulePath+"@"+version)
cmd.Dir = root 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() return cmd.CombinedOutput()
} }
if output, err := run("original-cache"); err != nil { if output, err := run("original-cache"); err != nil {