internal/pkg: drop cached error on cancel

This avoids disabling the artifact when using the individual cancel method. Unfortunately this makes the method blocking.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-18 03:20:44 +09:00
parent 27b1aaae38
commit 9e752b588a
3 changed files with 27 additions and 6 deletions

View File

@@ -911,7 +911,7 @@ func TestCache(t *testing.T) {
var started sync.WaitGroup
defer started.Wait()
blockCures := func(d byte, n int) {
blockCures := func(d byte, e stub.UniqueError, n int) {
started.Add(n)
for i := range n {
wg.Go(func() {
@@ -920,9 +920,9 @@ func TestCache(t *testing.T) {
cure: func(t *pkg.TContext) error {
started.Done()
<-t.Unwrap().Done()
return stub.UniqueError(0xbad0 + i)
return e + stub.UniqueError(i)
},
}}); !reflect.DeepEqual(err, stub.UniqueError(0xbad0+i)) {
}}); !reflect.DeepEqual(err, e+stub.UniqueError(i)) {
panic(err)
}
})
@@ -930,15 +930,26 @@ func TestCache(t *testing.T) {
started.Wait()
}
blockCures(0xfd, 16)
blockCures(0xfd, 0xbad, 16)
c.Abort()
wg.Wait()
blockCures(0xff, 1)
blockCures(0xfd, 0xcafe, 16)
c.Abort()
wg.Wait()
blockCures(0xff, 0xbad, 1)
if !c.Cancel(unique.Make(pkg.ID{0xff})) {
t.Fatal("missed cancellation")
}
wg.Wait()
blockCures(0xff, 0xcafe, 1)
if !c.Cancel(unique.Make(pkg.ID{0xff})) {
t.Fatal("missed cancellation")
}
wg.Wait()
for c.Cancel(unique.Make(pkg.ID{0xff})) {
}