diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-15 22:05:24 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-15 23:30:43 +0900 |
| commit | 3499a82785f8cb82bfe528875391d76d5e03c3de (patch) | |
| tree | 66d82b1a95fc3137cfb7a2ffa82af0d84b613aa0 /internal/pkg/exec_test.go | |
| parent | 088d35e4e65f1a22d32ac66d223672ed923fa328 (diff) | |
internal/pkg: cache computed identifiers
This eliminates duplicate identifier computations. The new implementation also significantly reduces allocations while computing identifier for a large dependency tree.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/exec_test.go')
| -rw-r--r-- | internal/pkg/exec_test.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/pkg/exec_test.go b/internal/pkg/exec_test.go index 97f72a38..558ab39b 100644 --- a/internal/pkg/exec_test.go +++ b/internal/pkg/exec_test.go @@ -50,7 +50,7 @@ func TestExec(t *testing.T) { nil, nil, nil, )), - pkg.MustPath("/.hakurei", false, stubArtifact{ + pkg.MustPath("/.hakurei", false, &stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(t *pkg.TContext) error { @@ -67,7 +67,7 @@ func TestExec(t *testing.T) { check.MustAbs("/opt/bin/testtool"), []string{"testtool"}, - pkg.MustPath("/proc/nonexistent", false, stubArtifact{ + pkg.MustPath("/proc/nonexistent", false, &stubArtifact{ kind: pkg.KindTar, params: []byte("doomed artifact"), cure: func(t *pkg.TContext) error { @@ -124,7 +124,7 @@ func TestExec(t *testing.T) { nil, nil, nil, )), - pkg.MustPath("/.hakurei", false, stubArtifact{ + pkg.MustPath("/.hakurei", false, &stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(t *pkg.TContext) error { @@ -150,7 +150,7 @@ func TestExec(t *testing.T) { check.MustAbs("/opt/bin/testtool"), []string{"testtool"}, - pkg.MustPath("/", true, stubArtifact{ + pkg.MustPath("/", true, &stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(t *pkg.TContext) error { @@ -176,13 +176,13 @@ func TestExec(t *testing.T) { check.MustAbs("/work/bin/testtool"), []string{"testtool"}, - pkg.MustPath("/", true, stubArtifact{ + pkg.MustPath("/", true, &stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(t *pkg.TContext) error { return os.MkdirAll(t.GetWorkDir().String(), 0700) }, - }), pkg.MustPath("/work/", false, stubArtifact{ + }), pkg.MustPath("/work/", false, &stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(t *pkg.TContext) error { @@ -207,13 +207,13 @@ func TestExec(t *testing.T) { check.MustAbs("/opt/bin/testtool"), []string{"testtool", "layers"}, - pkg.MustPath("/", true, stubArtifact{ + pkg.MustPath("/", true, &stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(t *pkg.TContext) error { return os.MkdirAll(t.GetWorkDir().String(), 0700) }, - }, stubArtifactF{ + }, &stubArtifactF{ kind: pkg.KindExec, params: []byte("test sample with dependencies"), @@ -222,7 +222,7 @@ func TestExec(t *testing.T) { pkg.ID{0xfe, 0}, nil, nil, nil, - ), stubArtifact{ + ), &stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), @@ -255,7 +255,7 @@ func newTesttool() ( testtoolDestroy func(t *testing.T, base *check.Absolute, c *pkg.Cache), ) { // testtoolBin is built during go:generate and is not deterministic - testtool = overrideIdent{pkg.ID{0xfe, 0xff}, stubArtifact{ + testtool = overrideIdent{pkg.ID{0xfe, 0xff}, &stubArtifact{ kind: pkg.KindTar, cure: func(t *pkg.TContext) error { work := t.GetWorkDir() |
