Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatskaari committed Jan 22, 2025
1 parent eab8873 commit e2b6df6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
22 changes: 15 additions & 7 deletions src/core/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,27 @@ func (graph *BuildGraph) TransitiveSubincludes(l BuildLabel) []BuildLabel {
graph.subincMux.RLock()
defer graph.subincMux.RUnlock()

return graph.transitiveSubincludes(l)
}
incs := make(labelSet)
graph.findTransitiveSubincludes(l, incs)

func (graph *BuildGraph) transitiveSubincludes(l BuildLabel) []BuildLabel {
ls := graph.subincludeSubincludes[l]
ret := make([]BuildLabel, 0, len(ls))
for l := range ls {
ret := make(BuildLabels, 0, len(incs))
for l := range incs {
ret = append(ret, l)
ret = append(ret, graph.transitiveSubincludes(l)...)
}
sort.Sort(ret)
return ret
}

func (graph *BuildGraph) findTransitiveSubincludes(label BuildLabel, includes labelSet) {
if _, ok := includes[label]; ok {
return
}
includes[label] = struct{}{}
for l := range graph.subincludeSubincludes[label] {
graph.findTransitiveSubincludes(l, includes)
}
}

func (graph *BuildGraph) RegisterTransitiveSubinclude(from, to BuildLabel) {
graph.subincMux.Lock()
defer graph.subincMux.Unlock()
Expand Down
4 changes: 3 additions & 1 deletion src/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ var log = logging.Log
func ToDir(state *core.BuildState, dir string, targets []core.BuildLabel) {
done := map[*core.BuildTarget]bool{}
for _, target := range state.Config.Parse.PreloadSubincludes {
exportSubinclude(state.Graph, dir, target, done)
for _, includeLable := range append(state.Graph.TransitiveSubincludes(target), target) {
export(state.Graph, dir, state.Graph.TargetOrDie(includeLable), done)
}
}
for _, target := range targets {
export(state.Graph, dir, state.Graph.TargetOrDie(target), done)
Expand Down
6 changes: 6 additions & 0 deletions test/export/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
subinclude("//test/build_defs")

plz_e2e_test(
name = "export_src_please_test",
cmd = "plz export --output plz-out/plzexport //src:please && plz --repo_root=$(plz query reporoot)/plz-out/plzexport build //src:please",
)

0 comments on commit e2b6df6

Please sign in to comment.