aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/pkg_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-02-03 09:50:35 +0900
committerOphestra <cat@gensokyo.uk>2026-02-03 10:01:44 +0900
commitf982b13a59a59e22d1ff3fdf791c1aa86b9420df (patch)
tree5d65ec444eba5b187fcce2979db98e929f2522c9 /internal/pkg/pkg_test.go
parent443911ada191fdd8848709824a03e228a72a86e0 (diff)
internal/pkg: improve error resolution
This was taking way too long for early failures. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/pkg_test.go')
-rw-r--r--internal/pkg/pkg_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go
index 719bf718..d03cd833 100644
--- a/internal/pkg/pkg_test.go
+++ b/internal/pkg/pkg_test.go
@@ -15,6 +15,7 @@ import (
"os"
"path/filepath"
"reflect"
+ "strconv"
"syscall"
"testing"
"unique"
@@ -1137,6 +1138,40 @@ func TestDependencyCureError(t *testing.T) {
}
}
+// earlyFailureF is a [FloodArtifact] with a large dependency graph resulting in
+// a large [DependencyCureError].
+type earlyFailureF int
+
+func (earlyFailureF) Kind() pkg.Kind { return pkg.KindExec }
+func (earlyFailureF) Params(*pkg.IContext) {}
+func (earlyFailureF) IsExclusive() bool { return false }
+
+func (a earlyFailureF) Dependencies() []pkg.Artifact {
+ deps := make([]pkg.Artifact, a)
+ for i := range deps {
+ deps[i] = a - 1
+ }
+ return deps
+}
+
+func (a earlyFailureF) Cure(*pkg.FContext) error {
+ if a != 0 {
+ panic("unexpected cure on " + strconv.Itoa(int(a)))
+ }
+ return stub.UniqueError(0xcafe)
+}
+
+func TestDependencyCureErrorEarly(t *testing.T) {
+ checkWithCache(t, []cacheTestCase{
+ {"early", nil, func(t *testing.T, _ *check.Absolute, c *pkg.Cache) {
+ _, _, err := c.Cure(earlyFailureF(8))
+ if !errors.Is(err, stub.UniqueError(0xcafe)) {
+ t.Fatalf("Cure: error = %v", err)
+ }
+ }, pkg.MustDecode("E4vEZKhCcL2gPZ2Tt59FS3lDng-d_2SKa2i5G_RbDfwGn6EemptFaGLPUDiOa94C")},
+ })
+}
+
func TestNew(t *testing.T) {
t.Parallel()