depgraph: Walk finishes all non-dependent trees
This commit is contained in:
parent
9573d1bfec
commit
397cf82c96
|
@ -3,6 +3,7 @@
|
|||
BUG FIXES:
|
||||
|
||||
* core: Providers are validated even without a `provider` block. [GH-284]
|
||||
* core: In the case of error, walk all non-dependent trees.
|
||||
|
||||
## 0.2.2 (September 9, 2014)
|
||||
|
||||
|
|
|
@ -269,7 +269,6 @@ func (g *Graph) Walk(fn WalkFunc) error {
|
|||
|
||||
// Spawn off all our goroutines to walk the tree
|
||||
errCh := make(chan error)
|
||||
quitCh := make(chan struct{})
|
||||
for len(tovisit) > 0 {
|
||||
// Grab the current thing to use
|
||||
n := len(tovisit)
|
||||
|
@ -301,11 +300,8 @@ func (g *Graph) Walk(fn WalkFunc) error {
|
|||
ch := seenMap[dep.Target]
|
||||
seenMapL.RUnlock()
|
||||
|
||||
select {
|
||||
case <-ch:
|
||||
case <-quitCh:
|
||||
return
|
||||
}
|
||||
// Wait for the dep to be run
|
||||
<-ch
|
||||
|
||||
// Check if any dependencies errored. If so,
|
||||
// then return right away, we won't walk it.
|
||||
|
@ -343,9 +339,6 @@ func (g *Graph) Walk(fn WalkFunc) error {
|
|||
case <-doneCh:
|
||||
return nil
|
||||
case err := <-errCh:
|
||||
// Close the quit channel so all our goroutines will end now
|
||||
close(quitCh)
|
||||
|
||||
// Drain the error channel
|
||||
go func() {
|
||||
for _ = range errCh {
|
||||
|
|
|
@ -389,7 +389,11 @@ c -> e`)
|
|||
func TestGraphWalk_error(t *testing.T) {
|
||||
nodes := ParseNouns(`a -> b
|
||||
b -> c
|
||||
a -> d`)
|
||||
a -> d
|
||||
a -> e
|
||||
e -> f
|
||||
f -> g
|
||||
g -> h`)
|
||||
list := NounMapToList(nodes)
|
||||
g := &Graph{Name: "Test", Nouns: list}
|
||||
if err := g.Validate(); err != nil {
|
||||
|
@ -419,7 +423,7 @@ a -> d`)
|
|||
|
||||
sort.Strings(walked)
|
||||
|
||||
expected := []string{"b", "c", "d"}
|
||||
expected := []string{"b", "c", "d", "e", "f", "g", "h"}
|
||||
if !reflect.DeepEqual(walked, expected) {
|
||||
t.Fatalf("bad: %#v", walked)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue