From ce0064384d782166b2b4d9277be49fd52872f34f Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 6 Jan 2026 22:19:47 +0900 Subject: internal/pkg: automatic overlay mount on root This makes it possible to use an Artifact as root without arranging for directory creation in the Artifact ahead of time. Signed-off-by: Ophestra --- internal/pkg/exec_test.go | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'internal/pkg/exec_test.go') diff --git a/internal/pkg/exec_test.go b/internal/pkg/exec_test.go index 5a14f786..76bb7566 100644 --- a/internal/pkg/exec_test.go +++ b/internal/pkg/exec_test.go @@ -26,6 +26,10 @@ var testtoolBin []byte func TestExec(t *testing.T) { t.Parallel() + wantChecksumOffline := pkg.MustDecode( + "GPa4aBakdSJd7Tz7LYj_VJFoojzyZinmVcG3k6M5xI6CZ821J5sXLhLDDuS47gi9", + ) + checkWithCache(t, []cacheTestCase{ {"offline", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { c.SetStrict(true) @@ -59,9 +63,7 @@ func TestExec(t *testing.T) { }, }), pkg.MustPath("/opt", testtool), - ), ignorePathname, pkg.MustDecode( - "GPa4aBakdSJd7Tz7LYj_VJFoojzyZinmVcG3k6M5xI6CZ821J5sXLhLDDuS47gi9", - ), nil}, + ), ignorePathname, wantChecksumOffline, nil}, {"error passthrough", pkg.NewExec( t.Context(), @@ -155,6 +157,38 @@ func TestExec(t *testing.T) { testtoolDestroy(t, base, c) }, pkg.MustDecode("bBQVFIt0FnOulljgpLnGtuzHSFgwiCMjc4pmc4rHRqXKQ60Q5aBVYp5f6aH9VdZi")}, + + {"overlay root", 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()) + + cureMany(t, c, []cureStep{ + {"container", pkg.NewExec( + t.Context(), + msg, + 0, + nil, + check.MustAbs("/work"), + []string{"HAKUREI_TEST=1", "HAKUREI_ROOT=1"}, + check.MustAbs("/opt/bin/testtool"), + []string{"testtool"}, + + pkg.MustPath("/", 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, wantChecksumOffline, nil}, + }) + + testtoolDestroy(t, base, c) + }, pkg.MustDecode("gFT9kprYBqEJKifJIl2sHn_3TgULWVLTU4DrYAHiGcRmcdFRZ0YtjiROW820cAEc")}, }) } -- cgit v1.3.1