From 156096ac987f5ec8be8dbf65332c4d61e675f3cf Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 6 Jan 2026 20:57:43 +0900 Subject: internal/pkg: known checksum exec artifact This optionally attaches an output checksum to an execArtifact and enables host networking for the resulting container. Signed-off-by: Ophestra --- internal/pkg/exec_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'internal/pkg/exec_test.go') diff --git a/internal/pkg/exec_test.go b/internal/pkg/exec_test.go index 0ac06010..1b2f84a8 100644 --- a/internal/pkg/exec_test.go +++ b/internal/pkg/exec_test.go @@ -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")}, }) } -- cgit v1.3.1