mesh-delivery-indexer: the requirements state reads the go.sum whatever packages the reader carried
With the go.mod's mesh requires carried at every take-in, requirementsOf returned early for every module requiring a mesh package: its go.sum was never read and keepRequirements never cleared an old version it named (indexer_requirements for mesh-sdk still names v0.1.13). The go.sum is read whenever its hash moved or this process has not kept it yet. Builds: design 47 H H-A-157 (review round 1)
This commit is contained in:
@@ -413,11 +413,11 @@ func (ix *Indexer) goModOf(ctx context.Context, f whole, dir string) ([]byte, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// requirementsOf keeps what the go.sum of the merge's directory dir requires in the requirements state
|
// requirementsOf keeps what the go.sum of the merge's directory dir requires in the requirements state
|
||||||
// (keepRequirements): read from the forge (GoSum) when no mesh package was carried and its hash moved, or this process
|
// (keepRequirements): read from the forge (GoSum) when its hash moved, or this process has not kept it yet, whatever
|
||||||
// has not kept it yet. It gives no package: those are the go.mod's (H-A-157).
|
// packages the reader carried. It gives no package: those are the go.mod's (H-A-157).
|
||||||
func (ix *Indexer) requirementsOf(ctx context.Context, f whole, dir string, cur meshcatalog.ModulesByModuleValue, has bool) {
|
func (ix *Indexer) requirementsOf(ctx context.Context, f whole, dir string, cur meshcatalog.ModulesByModuleValue, has bool) {
|
||||||
hash := f.Locks[dir]["go.sum"]
|
hash := f.Locks[dir]["go.sum"]
|
||||||
if len(f.Packages[dir]) > 0 || hash == "" || ix.GoSum == nil {
|
if hash == "" || ix.GoSum == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if has && cur.Inputs2 != nil && trunk.SameRepository(cur.Repository, f.Repository) && ix.requirementsKept(f.Repository, dir) {
|
if has && cur.Inputs2 != nil && trunk.SameRepository(cur.Repository, f.Repository) && ix.requirementsKept(f.Repository, dir) {
|
||||||
|
|||||||
@@ -401,16 +401,36 @@ func TestARootModuleHasTheDirectoryDot(t *testing.T) { // 1615/AC3: empty means
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAMergeAddingAModuleDirectoryWritesItsValueWithNoBuildRecordAnywhere(t *testing.T) { // I1: issue 1851, ADR 0501 clause 6
|
func TestAMergeAddingAModuleDirectoryWritesItsValueWithNoBuildRecordAnywhere(t *testing.T) { // I1: issue 1851, ADR 0501 clause 6
|
||||||
ix, mods, _ := manifestsIndexer(t) // no build record of any module
|
|
||||||
// Its go.mod requires mesh-sdk at the zero version, which its go.sum does not name (ADR 0573 §2): the go.mod's
|
|
||||||
// require lines are its mesh packages, with no build (design 47 H-A-157).
|
|
||||||
ix.GoMod = func(context.Context, string, string, string) ([]byte, error) {
|
|
||||||
return []byte("module avahi\n\nrequire " + meshSDK + " v0.0.0-00010101000000-000000000000\n"), nil
|
|
||||||
}
|
|
||||||
ix.GoSum = func(context.Context, string, string, string) ([]byte, error) {
|
|
||||||
return []byte("github.com/nats-io/nats.go v1.37.0 h1:x=\n"), nil
|
|
||||||
}
|
|
||||||
avahi := catalogueManifest(t, "avahi")
|
avahi := catalogueManifest(t, "avahi")
|
||||||
|
// Its go.mod requires mesh-sdk at the zero version (ADR 0573 §2): the go.mod's require lines are its mesh packages, with
|
||||||
|
// no build, carried by the reader or read through GoMod (design 47 H-A-157). Its go.sum is still read for the
|
||||||
|
// requirements state, carried packages or not, so an older version it names is kept there (and cleared when gone).
|
||||||
|
for _, carried := range [][]string{nil, {meshSDK}} {
|
||||||
|
ix, mods, _ := manifestsIndexer(t)
|
||||||
|
ix.Requirements = newMem()
|
||||||
|
ix.GoMod = func(context.Context, string, string, string) ([]byte, error) {
|
||||||
|
return []byte("module avahi\n\nrequire " + meshSDK + " v0.0.0-00010101000000-000000000000\n"), nil
|
||||||
|
}
|
||||||
|
ix.GoSum = func(context.Context, string, string, string) ([]byte, error) {
|
||||||
|
return []byte(meshSDK + " v0.1.14 h1:x=\n"), nil
|
||||||
|
}
|
||||||
|
f := withManifests(mergedMsg(catalogueRepo, map[string]string{"modules/avahi": "newtree"}), map[string]string{"modules/avahi": avahi},
|
||||||
|
map[string]map[string]string{"modules/avahi": {"go.sum": avahiGoSum}})
|
||||||
|
if carried != nil {
|
||||||
|
f.Packages = map[string][]string{"modules/avahi": carried}
|
||||||
|
}
|
||||||
|
if err := ix.Apply(context.Background(), f); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
m, _ := moduleOf(t, mods, "avahi")
|
||||||
|
if m.Inputs2 == nil || !slices.Equal(m.Inputs2.Packages, []string{meshSDK}) {
|
||||||
|
t.Errorf("carried %v: mesh packages %+v, want mesh-sdk, which its go.mod requires at the zero version", carried, m.Inputs2)
|
||||||
|
}
|
||||||
|
if _, kept := ix.Requirements.(*memStore).vals[meshSDK]; !kept {
|
||||||
|
t.Errorf("carried %v: the requirements state holds no %s, which the go.sum names", carried, meshSDK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ix, mods, _ := manifestsIndexer(t) // no build record of any module
|
||||||
f := withManifests(mergedMsg(catalogueRepo, map[string]string{"modules/avahi": "newtree"}), map[string]string{"modules/avahi": avahi},
|
f := withManifests(mergedMsg(catalogueRepo, map[string]string{"modules/avahi": "newtree"}), map[string]string{"modules/avahi": avahi},
|
||||||
map[string]map[string]string{"modules/avahi": {"go.sum": avahiGoSum}})
|
map[string]map[string]string{"modules/avahi": {"go.sum": avahiGoSum}})
|
||||||
if err := ix.Apply(context.Background(), f); err != nil {
|
if err := ix.Apply(context.Background(), f); err != nil {
|
||||||
@@ -420,9 +440,6 @@ func TestAMergeAddingAModuleDirectoryWritesItsValueWithNoBuildRecordAnywhere(t *
|
|||||||
if !ok || m.Path != "modules/avahi" || m.Repository != catalogueRepo || m.Commit != merge || m.Manifest != meshcatalogclient.ManifestDigest([]byte(avahi)) || m.Inputs2 == nil || m.Inputs2.Tree != "newtree" {
|
if !ok || m.Path != "modules/avahi" || m.Repository != catalogueRepo || m.Commit != merge || m.Manifest != meshcatalogclient.ManifestDigest([]byte(avahi)) || m.Inputs2 == nil || m.Inputs2.Tree != "newtree" {
|
||||||
t.Fatalf("module = %+v (%v), want its directory, merge, manifest and inputs from the message alone", m, ok)
|
t.Fatalf("module = %+v (%v), want its directory, merge, manifest and inputs from the message alone", m, ok)
|
||||||
}
|
}
|
||||||
if !slices.Equal(m.Inputs2.Packages, []string{meshSDK}) {
|
|
||||||
t.Errorf("mesh packages %v, want mesh-sdk, which its go.mod requires at the zero version", m.Inputs2.Packages)
|
|
||||||
}
|
|
||||||
if m.Fp != "" || m.None != "" {
|
if m.Fp != "" || m.None != "" {
|
||||||
t.Errorf("module = %+v, want no value of today's form (I4: it came from the build records)", m)
|
t.Errorf("module = %+v, want no value of today's form (I4: it came from the build records)", m)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user