Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a98b6ba77e | ||
|
|
b1125c02cf | ||
|
|
a4bc3d95ed | ||
|
|
6ba73d4e2a |
@@ -0,0 +1,3 @@
|
||||
// Package buildstep is kept empty as a bridge: the running pre-G indexer publishes mesh-catalog's packages only while
|
||||
// every package directory it published before is in the tree. It goes once G's indexer runs.
|
||||
package buildstep
|
||||
@@ -456,7 +456,8 @@ func (k *Keeper) statusWritten(s Status, err error) {
|
||||
// watched branch's newest revision is applied (Heard), a module of the new form that sends gets its sent store, a drift
|
||||
// between branches is said once, and a module in no watched branch's newest revision has its plans key deleted, its
|
||||
// entries then orphans. Before every watched branch has its first view it plans nothing, and says what it waits for in
|
||||
// its status; the first plan checks what is held.
|
||||
// its status, and an answer listing no module before one has listed any is the same (none-yet); the first plan checks what
|
||||
// is held.
|
||||
func (k *Keeper) PlanCatalog() error {
|
||||
at := k.now()
|
||||
view, err := k.Catalog()
|
||||
@@ -466,6 +467,15 @@ func (k *Keeper) PlanCatalog() error {
|
||||
}
|
||||
k.mu.Lock()
|
||||
first := !k.viewed
|
||||
// A catalog half with no module in it before any has been seen is a trunk with no revision yet (`none-yet`, design 47
|
||||
// G A-367): not yet viewed, so nothing is planned, no plan deleted and no entry made an orphan for want of knowledge.
|
||||
if first && len(view.Modules) == 0 {
|
||||
k.mu.Unlock()
|
||||
k.setStatus(func(s *Status) {
|
||||
s.FirstView.Asked, s.FirstView.Error = at, "the catalog half lists no module yet (none-yet): nothing is planned or orphaned until a revision lists one"
|
||||
})
|
||||
return nil
|
||||
}
|
||||
k.viewed = true
|
||||
k.mu.Unlock()
|
||||
var revision uint64
|
||||
|
||||
@@ -450,6 +450,9 @@ func TestTheKeeperMakesWhatAVerdictAsksForAndSaysIt(t *testing.T) {
|
||||
if len(bus.created) != 0 {
|
||||
t.Fatalf("created %v before the first view", bus.created)
|
||||
}
|
||||
k.Catalog = func() (CatalogView, error) {
|
||||
return CatalogView{Modules: []CatalogModule{{Accepted: Accepted{Module: "m", Digest: "d1", Revision: 3, BusState: []catalogue.BusStateEntry{drafts}}}}}, nil
|
||||
}
|
||||
if err := k.PlanCatalog(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -541,6 +544,37 @@ func TestTheKeeperMakesWhatAVerdictAsksForAndSaysIt(t *testing.T) {
|
||||
t.Errorf("old sections %d: 8 MiB counted", k.Status().OldBytes)
|
||||
}
|
||||
}},
|
||||
// A-367: a trunk with no revision yet (none-yet) is not yet viewed: nothing is planned, deleted or orphaned.
|
||||
{"a none-yet catalog half plans nothing and orphans nothing until a module is listed", func(t *testing.T, k *Keeper, bus *fakeBus, out *said) {
|
||||
k.Heard(Accepted{Module: "m", Revision: 9, BusState: []catalogue.BusStateEntry{drafts}})
|
||||
k.Catalog = func() (CatalogView, error) {
|
||||
return CatalogView{Modules: []CatalogModule{{Accepted: Accepted{Module: "m", Revision: 9, BusState: []catalogue.BusStateEntry{drafts}}}}}, nil
|
||||
}
|
||||
_ = k.PlanCatalog()
|
||||
k.mu.Lock()
|
||||
k.viewed = false
|
||||
k.mu.Unlock()
|
||||
k.Catalog = func() (CatalogView, error) { return CatalogView{}, nil }
|
||||
if err := k.PlanCatalog(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, ok := k.planned("m"); !ok {
|
||||
t.Error("m's plan is deleted by a none-yet view")
|
||||
}
|
||||
if a := k.Held()["m"]; a.Made["drafts"].Orphaned {
|
||||
t.Errorf("held %+v: drafts orphaned by a none-yet view", a)
|
||||
}
|
||||
if k.Viewed() || !strings.Contains(k.Status().FirstView.Error, "none-yet") {
|
||||
t.Errorf("viewed %v, status %+v: none-yet is not a first view and says so", k.Viewed(), k.Status().FirstView)
|
||||
}
|
||||
k.Catalog = func() (CatalogView, error) {
|
||||
return CatalogView{Modules: []CatalogModule{{Accepted: Accepted{Module: "m", Revision: 10, BusState: []catalogue.BusStateEntry{drafts}}}}}, nil
|
||||
}
|
||||
_ = k.PlanCatalog()
|
||||
if !k.Viewed() || k.Status().FirstView.Error != "" {
|
||||
t.Error("the first revision with entries is viewed and plans as before")
|
||||
}
|
||||
}},
|
||||
// §538: a module in no watched branch's newest revision has its plans key deleted, its entries then orphans.
|
||||
{"a module no watched branch lists loses its plan, its entries orphans", func(t *testing.T, k *Keeper, bus *fakeBus, out *said) {
|
||||
k.Catalog = func() (CatalogView, error) {
|
||||
@@ -1240,9 +1274,11 @@ func TestTheKeeperMakesWhatAVerdictAsksForAndSaysIt(t *testing.T) {
|
||||
} {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
k, bus, _, out := newKeeper(CatalogView{})
|
||||
if err := k.PlanCatalog(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The rows start after the first view: an empty answer is none-yet (A-367), so the view is marked answered here.
|
||||
k.mu.Lock()
|
||||
k.viewed = true
|
||||
k.mu.Unlock()
|
||||
k.setStatus(func(s *Status) { s.FirstView.Asked, s.FirstView.Answered = k.now(), k.now() })
|
||||
row.run(t, k, bus, out)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user