Test that a load failing on a read nothing provides names every module the loaded manifests read
This commit is contained in:
@@ -9,40 +9,29 @@ import (
|
||||
// loadSources merges sources in order, the last winning a clash. A source whose manifest
|
||||
// carries an index leaves its categories unloaded; every other source loads here, with
|
||||
// the unloaded categories it needs.
|
||||
// docs/decisions.md#a-source-whose-manifest-carries-an-index-loads-each-category-on-first-reach-any-other-loads-in-new-with-what-it-reads
|
||||
func loadSources(sources []datafiles.Source) (folder, error) {
|
||||
root := folder{children: map[string]node{}}
|
||||
walked := map[string][]string{}
|
||||
for _, src := range sources {
|
||||
if err := addSource(&root, src, walked); err != nil {
|
||||
if err := addSource(&root, src); err != nil {
|
||||
return folder{}, err
|
||||
}
|
||||
}
|
||||
sites := categorySites(&root)
|
||||
for i := range sites {
|
||||
sites[i].defaultModules = walked[sites[i].path]
|
||||
}
|
||||
return root, loadReached(&root, sites, nil)
|
||||
return root, loadReached(&root, categorySites(&root), nil)
|
||||
}
|
||||
|
||||
// addSource places src's categories in root. For each category it loads now, it records in
|
||||
// walked the modules src reads by default.
|
||||
func addSource(root *folder, src datafiles.Source, walked map[string][]string) error {
|
||||
func addSource(root *folder, src datafiles.Source) error {
|
||||
m, err := src.Manifest()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if m.Index != nil {
|
||||
placeIndex(root, src, m)
|
||||
placeIndex(root, src, m.Index)
|
||||
return nil
|
||||
}
|
||||
g := &folder{children: map[string]node{}}
|
||||
if err := src.Walk(compileInto(func(dir []string) *folder { return madeFolder(g, dir) })); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, s := range categorySites(g) {
|
||||
walked[s.path] = m.Reads
|
||||
}
|
||||
mergeFolder(root, g)
|
||||
return nil
|
||||
}
|
||||
@@ -88,13 +77,11 @@ func mergeFolder(dst, src *folder) {
|
||||
// single inline node.
|
||||
type nodeSet func(fn func(label string, n node) error) error
|
||||
|
||||
// categorySite is a loaded category, where it sits, its own dot path, and the modules its
|
||||
// source reads by default.
|
||||
// categorySite is a loaded category, where it sits and its own dot path.
|
||||
type categorySite struct {
|
||||
categoryAt
|
||||
n node
|
||||
path string
|
||||
defaultModules []string
|
||||
n node
|
||||
path string
|
||||
}
|
||||
|
||||
// categorySites lists every category under root, folders and names in sorted order.
|
||||
|
||||
Reference in New Issue
Block a user