From 0df87ab1117bf4da5163ad486a82628f1bada7ed Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 6 Jan 2026 23:34:43 +0900 Subject: internal/pkg: automatic overlay mount on tmp This sets up the last Artifact to target /tmp as a writable overlay mount backed by the host side temp directory. This is useful for an Artifact containing source code to be built for another Artifact for example. Signed-off-by: Ophestra --- internal/pkg/exec_test.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'internal/pkg/exec_test.go') diff --git a/internal/pkg/exec_test.go b/internal/pkg/exec_test.go index 76bb7566..d1b88766 100644 --- a/internal/pkg/exec_test.go +++ b/internal/pkg/exec_test.go @@ -11,6 +11,7 @@ import ( "testing" "hakurei.app/container/check" + "hakurei.app/container/fhs" "hakurei.app/container/stub" "hakurei.app/hst" "hakurei.app/internal/pkg" @@ -189,6 +190,48 @@ func TestExec(t *testing.T) { testtoolDestroy(t, base, c) }, pkg.MustDecode("gFT9kprYBqEJKifJIl2sHn_3TgULWVLTU4DrYAHiGcRmcdFRZ0YtjiROW820cAEc")}, + + {"overlay temp", 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("/tmp/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("/tmp/", stubArtifact{ + kind: pkg.KindTar, + params: []byte("empty directory"), + cure: func(c *pkg.CureContext) error { + return os.MkdirAll(c.GetWorkDir().String(), 0700) + }, + }), + pkg.ExecContainerPath{ + P: fhs.AbsTmp, + A: testtool, + }, + ), ignorePathname, wantChecksumOffline, nil}, + }) + + testtoolDestroy(t, base, c) + }, pkg.MustDecode("_r1IBeMWCkLwQ9Im9w0tV9_CWIOfQlXkkP2CogPHLmZp_AB6W3_8HVZqDV00dNAm")}, }) } -- cgit v1.3.1