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