1
0
forked from rosa/hakurei

internal/pkg: check exec substitution

This relies on the testtool having ident as relevant input to assert successful substitution.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-13 19:43:53 +09:00
parent 8c2dd3e984
commit a759cf3666
2 changed files with 50 additions and 13 deletions

View File

@@ -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)
}
}