Catch-up take-in.taken: tests for the tool's path and the held start inside TakenIn; count only fully taken repositories; spend the source number only when said
Builds: design 47 G A-490k, A-463, A-464, §493 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -114,7 +114,17 @@ func TestASourceRevisionHeardDuringACatchUpIsComparedWhenItEnds(t *testing.T) {
|
||||
}
|
||||
return inner(c, r, m, n)
|
||||
}
|
||||
b.ix.CatchUp(ctx)
|
||||
got := b.ix.CatchUp(ctx)
|
||||
// A-490k: the catch-up tool's own path says take-in.taken for the module it wrote.
|
||||
said := false
|
||||
for _, s := range b.said {
|
||||
if s.Kind == takein.TakeInTaken && len(s.Entries) == 1 && s.Entries[0].Module == "avahi" && s.Source > 0 {
|
||||
said = true
|
||||
}
|
||||
}
|
||||
if !got.Stored || !said {
|
||||
t.Errorf("the catch-up answered %+v and said %+v, want a take-in.taken naming avahi", got, b.said)
|
||||
}
|
||||
b.ix.catchUpWG.Wait()
|
||||
v, _, _, _ := b.ix.Taken.Get(ctx, key)
|
||||
if got, _ := takein.DecodeTaken(v); got.Merge != h2 {
|
||||
|
||||
@@ -220,7 +220,9 @@ func (ix *Indexer) takeInHeadsWritten(ctx context.Context, heads map[string]stri
|
||||
if err == nil {
|
||||
var a Applied
|
||||
a, err = ix.ApplyMessage(ctx, f)
|
||||
written = append(written, a.Written...)
|
||||
if err == nil {
|
||||
written = append(written, a.Written...)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
unread = append(unread, repository)
|
||||
@@ -250,8 +252,19 @@ func (ix *Indexer) sayCaughtUp(ctx context.Context, written []string, heads map[
|
||||
if len(merges) == 0 {
|
||||
return
|
||||
}
|
||||
ix.mu.Lock()
|
||||
was, had := ix.saidSource[TrunkBranch]
|
||||
ix.mu.Unlock()
|
||||
branch, src, took := ix.takenWhat(ctx, claimed, Applied{Written: written})
|
||||
if len(took) == 0 {
|
||||
// Nothing is said, so the source number is not spent (takenWhat took it).
|
||||
ix.mu.Lock()
|
||||
if had {
|
||||
ix.saidSource[branch] = was
|
||||
} else {
|
||||
delete(ix.saidSource, branch)
|
||||
}
|
||||
ix.mu.Unlock()
|
||||
return
|
||||
}
|
||||
revision := ix.PinPipelines(ctx, branch, src, took)
|
||||
|
||||
@@ -354,4 +354,22 @@ func TestATakeInBehindTheViewAsksTheViewAgainAndStartsTheHeldModulesWhenItReache
|
||||
if n, err := s.StartHeld("main", half); n != 0 || err != nil {
|
||||
t.Errorf("the held start ran twice: %d (%v)", n, err)
|
||||
}
|
||||
// The view reaching the revision while the take-in is read (its second read answers 12) starts the held modules inside
|
||||
// TakenIn, not at an advance that already came.
|
||||
mem2 := memStore{}
|
||||
s2 := &Starter{Pipelines: memCreated{mem2}, Store: mem2, Say: func(string, any) error { return nil }}
|
||||
reads := 0
|
||||
view2 := func(string) (Half, bool) {
|
||||
reads++
|
||||
if reads >= 2 {
|
||||
return Half{Revision: 12, Source: 9, Entries: entries}, true
|
||||
}
|
||||
return Half{Revision: 11, Source: 8, Entries: entries}, true
|
||||
}
|
||||
if n, err := s2.TakenIn(ev, view2); err != nil || n != 2 {
|
||||
t.Fatalf("the take-in whose view reached 12 meanwhile started %d (%v), want moved and batched", n, err)
|
||||
}
|
||||
if _, _, err := mem2.Get("main.9.batched"); err != nil {
|
||||
t.Errorf("main.9.batched is not started inside the take-in: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user