From: Daniel Pittman <[email protected]>
The SimpleGraph class was reporting duplicate data when printing cycles:
Notify[c]Notify[c] => Notify[d]
Notify[a]Notify[a] => Notify[b]
This was caused by throwing the array representation of the edge into a
string, rather than just the relationship data; we only care about the later,
so now we only emit that later and have the correct text in the error.
---
lib/puppet/simple_graph.rb | 8 +++++---
spec/unit/simple_graph_spec.rb | 6 ++++++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 9d7f218..29e46c9 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -109,7 +109,7 @@ class Puppet::SimpleGraph
# each of its out-edges.
while v = zeros.pop
result << v
- @out_from[v].each { |v2,es|
+ @out_from[v].each { |v2,es|
degree[v2].delete(v)
zeros << v2 if degree[v2].empty?
}
@@ -117,7 +117,9 @@ class Puppet::SimpleGraph
# If we have any vertices left with non-zero in-degrees, then we've found
a cycle.
if cycles = degree.values.reject { |ns| ns.empty? } and cycles.length > 0
- message = cycles.collect { |edges| '('+edges.collect { |e| e.to_s
}.join(", ")+')' }.join(", ")
+ message = cycles.collect { |edges|
+ '(' + edges.collect { |e| e[1].to_s }.join(", ") + ')'
+ }.join(", ")
raise Puppet::Error, "Found dependency cycles in the following
relationships: #{message}; try using the '--graph' option and open the '.dot'
files in OmniGraffle or GraphViz"
end
@@ -141,7 +143,7 @@ class Puppet::SimpleGraph
# each of its out-edges.
while v = zeros.pop
result << v
- @out_from[v].each { |v2,es|
+ @out_from[v].each { |v2,es|
zeros << v2 if (degree[v2] -= 1) == 0
}
end
diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb
index e49811e..0d1a3b4 100755
--- a/spec/unit/simple_graph_spec.rb
+++ b/spec/unit/simple_graph_spec.rb
@@ -303,6 +303,12 @@ describe Puppet::SimpleGraph do
proc { @graph.topsort }.should_not raise_error
end
+ it "should produce the correct relationship text" do
+ add_edges :a => :b, :b => :a
+ want = %r{following relationships: \(b => a\), \(a => b\)}
+ expect { @graph.topsort }.to raise_error(Puppet::Error, want)
+ end
+
# Our graph's add_edge method is smart enough not to add
# duplicate edges, so we use the objects, which it doesn't
# check.
--
1.7.3.5
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.