aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/leap_cli/commands/test.rb7
-rw-r--r--lib/leap_cli/config/node.rb8
-rw-r--r--lib/leap_cli/config/object_list.rb18
3 files changed, 32 insertions, 1 deletions
diff --git a/lib/leap_cli/commands/test.rb b/lib/leap_cli/commands/test.rb
index da4a4b5..024ca25 100644
--- a/lib/leap_cli/commands/test.rb
+++ b/lib/leap_cli/commands/test.rb
@@ -13,7 +13,12 @@ module LeapCli; module Commands
test.command :run do |run|
run.switch 'continue', :desc => 'Continue over errors and failures (default is --no-continue).', :negatable => true
run.action do |global_options,options,args|
- manager.filter!(args).each_node do |node|
+ test_order = File.join(Path.platform, 'tests/order.rb')
+ if File.exists?(test_order)
+ require test_order
+ end
+ manager.filter!(args).names_in_test_dependency_order.each do |node_name|
+ node = manager.nodes[node_name]
ssh_connect(node) do |ssh|
ssh.run(test_cmd(options))
end
diff --git a/lib/leap_cli/config/node.rb b/lib/leap_cli/config/node.rb
index 5b911bf..740f9bb 100644
--- a/lib/leap_cli/config/node.rb
+++ b/lib/leap_cli/config/node.rb
@@ -32,6 +32,14 @@ module LeapCli; module Config
end
return vagrant_range.include?(ip_address)
end
+
+ #
+ # can be overridden by the platform.
+ # returns a list of node names that should be tested before this node
+ #
+ def test_dependencies
+ []
+ end
end
end; end
diff --git a/lib/leap_cli/config/object_list.rb b/lib/leap_cli/config/object_list.rb
index 9ca4697..910e2f7 100644
--- a/lib/leap_cli/config/object_list.rb
+++ b/lib/leap_cli/config/object_list.rb
@@ -1,9 +1,12 @@
+require 'tsort'
+
module LeapCli
module Config
#
# A list of Config::Object instances (internally stored as a hash)
#
class ObjectList < Hash
+ include TSort
def initialize(config=nil)
if config
@@ -171,6 +174,21 @@ module LeapCli
end
end
+ #
+ # topographical sort based on test dependency
+ #
+ def tsort_each_node(&block)
+ self.each_key(&block)
+ end
+
+ def tsort_each_child(node_name, &block)
+ self[node_name].test_dependencies.each(&block)
+ end
+
+ def names_in_test_dependency_order
+ self.tsort
+ end
+
end
end
end