internal/pkg: garbage collection
All checks were successful
Test / Create distribution (push) Successful in 2m53s
Test / Sandbox (push) Successful in 7m2s
Test / ShareFS (push) Successful in 3m51s
Test / Hakurei (push) Successful in 3m58s
Test / Sandbox (race detector) (push) Successful in 5m32s
Test / Hakurei (race detector) (push) Successful in 6m35s
Test / Flake checks (push) Successful in 2m13s

This destroys cache entries not referred to by user-specified artifacts and optionally their inputs.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-06-01 14:51:40 +09:00
parent f398f71fa9
commit fbd2329d50
4 changed files with 484 additions and 5 deletions

View File

@@ -486,7 +486,17 @@ func checkWithCache(t *testing.T, testCases []cacheTestCase) {
tc.early(t, base)
}
tc.f(t, base, c)
scrubFunc = func() error { return c.Scrub(1 << 7) }
scrubFunc = func() error {
err = c.Scrub(1 << 7)
idents, checksums, cleanErr := c.Clean(false, false)
if len(idents) > 0 {
t.Errorf("destroyed %d idents", len(idents))
}
if len(checksums) > 0 {
t.Errorf("destroyed %d checksums", len(checksums))
}
return errors.Join(err, cleanErr)
}
}
var restoreTemp bool
@@ -561,10 +571,7 @@ func checkWithCache(t *testing.T, testCases []cacheTestCase) {
if err := pkg.HashDir(&checksum, base); err != nil {
t.Fatalf("HashDir: error = %v", err)
} else if checksum != want {
t.Fatalf("(scrubbed) HashDir: %v", &pkg.ChecksumMismatchError{
Got: checksum,
Want: want,
})
t.Fatalf("(scrubbed) %s", expectsFrom(base.String()))
}
})
}