aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/exec_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-01-06 22:19:47 +0900
committerOphestra <cat@gensokyo.uk>2026-01-06 22:19:47 +0900
commitce0064384d782166b2b4d9277be49fd52872f34f (patch)
treef4dfe1e5446f8b7bf41419306c560bef13d66964 /internal/pkg/exec_test.go
parent53d80f4b66848b046c4852e502779796e260463d (diff)
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 <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/exec_test.go')
-rw-r--r--internal/pkg/exec_test.go40
1 files changed, 37 insertions, 3 deletions
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")},
})
}