From fbd2329d50a9ef2b15c0a6b62e9aa24635c2662a Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 1 Jun 2026 14:51:40 +0900 Subject: internal/pkg: garbage collection This destroys cache entries not referred to by user-specified artifacts and optionally their inputs. Signed-off-by: Ophestra --- internal/pkg/pkg_test.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'internal/pkg/pkg_test.go') diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go index d5c92a6d..a4fb8361 100644 --- a/internal/pkg/pkg_test.go +++ b/internal/pkg/pkg_test.go @@ -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())) } }) } -- cgit v1.3.1