mesh/merge-gate head 92fdc8c86a17 merged into trunk 725590e06e75 — pass, with a note: builds mesh-sdk (+41 dependent(s)) → ace, g14, novox, shanks; no bus …
mesh/repo-check head 92fdc8c86a17 merged into trunk 725590e06e75 — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (typescript)…
mesh/delivery delivered
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"path/filepath"
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
// readManifest is one manifest of the catalogue as ReadTreeManifest read it.
|
|
type readManifest struct {
|
|
path string // the module.json
|
|
manifest Manifest
|
|
err error
|
|
}
|
|
|
|
var (
|
|
readOnce sync.Once
|
|
readAll []readManifest
|
|
readRoot string
|
|
)
|
|
|
|
// catalogueManifests is every manifest of the catalogue (catalogueRoot), read through ReadTreeManifest once
|
|
// per test binary and not once per test: the checks over the real catalogue each read and parsed every
|
|
// manifest again, and together took 1.5 s of mesh-sdk's unit bound of 2 s (issue 1756). What it returns is
|
|
// shared and read-only: a test that changes a manifest copies it first.
|
|
func catalogueManifests(t *testing.T) (string, []readManifest) {
|
|
t.Helper()
|
|
root := catalogueRoot(t)
|
|
readOnce.Do(func() {
|
|
readRoot = root
|
|
found, err := filepath.Glob(filepath.Join(root, "modules", "*", "module.json"))
|
|
if err != nil {
|
|
return
|
|
}
|
|
for _, p := range found {
|
|
m, err := ReadTreeManifest(root, filepath.Dir(p))
|
|
readAll = append(readAll, readManifest{path: p, manifest: m, err: err})
|
|
}
|
|
})
|
|
if len(readAll) == 0 {
|
|
t.Fatalf("no manifests under %s", root)
|
|
}
|
|
return readRoot, readAll
|
|
}
|