internal/pkg: known checksum exec artifact
All checks were successful
Test / Create distribution (push) Successful in 53s
Test / Sandbox (push) Successful in 2m57s
Test / ShareFS (push) Successful in 4m48s
Test / Sandbox (race detector) (push) Successful in 5m21s
Test / Hakurei (push) Successful in 5m31s
Test / Hpkg (push) Successful in 5m26s
Test / Hakurei (race detector) (push) Successful in 7m33s
Test / Flake checks (push) Successful in 1m49s

This optionally attaches an output checksum to an execArtifact and enables host networking for the resulting container.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-06 20:57:43 +09:00
parent ceb75538cf
commit 156096ac98
5 changed files with 179 additions and 8 deletions

View File

@@ -39,6 +39,7 @@ func TestExec(t *testing.T) {
t.Context(),
msg,
0,
nil,
check.MustAbs("/work"),
[]string{"HAKUREI_TEST=1"},
check.MustAbs("/opt/bin/testtool"),
@@ -66,6 +67,7 @@ func TestExec(t *testing.T) {
t.Context(),
msg,
0,
nil,
check.MustAbs("/work"),
[]string{"HAKUREI_TEST=1"},
check.MustAbs("/opt/bin/testtool"),
@@ -84,6 +86,7 @@ func TestExec(t *testing.T) {
t.Context(),
msg,
0,
nil,
check.MustAbs("/work"),
[]string{"HAKUREI_TEST=1"},
check.MustAbs("/opt/bin/testtool"),
@@ -99,6 +102,7 @@ func TestExec(t *testing.T) {
t.Context(),
msg,
0,
nil,
check.MustAbs("/work"),
nil,
check.MustAbs("/opt/bin/testtool"),
@@ -110,6 +114,47 @@ func TestExec(t *testing.T) {
testtoolDestroy(t, base, c)
}, pkg.MustDecode("7PoPpWLjFPXIymbuIYLZAzOpCYr-2PN4CZ11jFdO-mDlnZNgFO3JyOtK8HW8Jxvm")},
{"net", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) {
c.SetStrict(true)
testtool, testtoolDestroy := newTesttool()
msg := message.New(log.New(os.Stderr, "container: ", 0))
msg.SwapVerbose(testing.Verbose())
wantChecksum := pkg.MustDecode(
"a1F_i9PVQI4qMcoHgTQkORuyWLkC1GLIxOhDt2JpU1NGAxWc5VJzdlfRK-PYBh3W",
)
cureMany(t, c, []cureStep{
{"container", pkg.NewExec(
t.Context(),
msg,
0,
&wantChecksum,
check.MustAbs("/work"),
[]string{"HAKUREI_TEST=1"},
check.MustAbs("/opt/bin/testtool"),
[]string{"testtool", "net"},
pkg.MustPath("/file", newStubFile(
pkg.KindHTTPGet,
pkg.ID{0xfe, 0},
nil,
nil, nil,
)),
pkg.MustPath("/.hakurei", stubArtifact{
kind: pkg.KindTar,
params: []byte("empty directory"),
cure: func(c *pkg.CureContext) error {
return os.MkdirAll(c.GetWorkDir().String(), 0700)
},
}),
pkg.MustPath("/opt", testtool),
), ignorePathname, wantChecksum, nil},
})
testtoolDestroy(t, base, c)
}, pkg.MustDecode("bBQVFIt0FnOulljgpLnGtuzHSFgwiCMjc4pmc4rHRqXKQ60Q5aBVYp5f6aH9VdZi")},
})
}