From a759cf3666897e97d8437cd1b74356d20c7cadca Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 13 May 2026 19:43:53 +0900 Subject: internal/pkg: check exec substitution This relies on the testtool having ident as relevant input to assert successful substitution. Signed-off-by: Ophestra --- internal/pkg/pkg_test.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'internal/pkg/pkg_test.go') diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go index 0877e791..d5c92a6d 100644 --- a/internal/pkg/pkg_test.go +++ b/internal/pkg/pkg_test.go @@ -246,26 +246,37 @@ func newDestroyArtifactFunc(a pkg.Artifact) func( } // destroyStatus counts non-substitution status entries and destroys them. -func destroyStatus(t *testing.T, base *check.Absolute, n int) { +func destroyStatus(t *testing.T, base *check.Absolute, c, s int) { dents, err := os.ReadDir(base.Append("status").String()) if err != nil { t.Fatal(err) } + var gotC, gotS int for _, dent := range dents { - if !dent.Type().IsRegular() { - t.Errorf("%s: %s", dent.Name(), dent.Type()) - } if err = os.Remove(base.Append( "status", dent.Name(), ).String()); err != nil { t.Fatal(err) } + + if dent.Type().IsRegular() { + gotC++ + continue + } + if dent.Type()&fs.ModeSymlink == fs.ModeSymlink { + gotS++ + continue + } + t.Errorf("%s: %s", dent.Name(), dent.Type()) } - if len(dents) != n { - t.Errorf("ReadDir: %d entries, want %d", len(dents), n) + if gotC != c { + t.Errorf("status: c = %d, want %d", gotC, c) + } + if gotS != s { + t.Errorf("status: s = %d, want %d", gotS, s) } } -- cgit v1.3.1