From 19567504f45a1041a088a8b91e1eb323583661f5 Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 22 Jan 2015 14:11:15 -0800 Subject: added support for custom tests in files/tests --- bin/run_tests | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'bin/run_tests') diff --git a/bin/run_tests b/bin/run_tests index 44384379..8eab5286 100755 --- a/bin/run_tests +++ b/bin/run_tests @@ -16,7 +16,7 @@ require 'yaml' require 'tsort' ## -## EXIT CODES +## CONSTANTS ## EXIT_CODES = { @@ -26,6 +26,20 @@ EXIT_CODES = { :error => 3 } +HIERA_FILE = '/etc/leap/hiera.yaml' +HELPER_PATHS = [ + '../../tests/helpers/*.rb', + '/srv/leap/files/tests/helpers/*.rb' +] +TEST_PATHS = [ + '../../tests/white-box/*.rb', + '/srv/leap/files/tests/white-box/*.rb' +] + +## +## UTILITY +## + def bail(code, msg=nil) puts msg if msg if code.is_a? Symbol @@ -35,10 +49,6 @@ def bail(code, msg=nil) end end -## -## UTILITY -## - def service?(service) $node["services"].include?(service.to_s) end @@ -417,21 +427,25 @@ end def main # load node data from hiera file - if File.exists?('/etc/leap/hiera.yaml') - $node = YAML.load_file('/etc/leap/hiera.yaml') + if File.exists?(HIERA_FILE) + $node = YAML.load_file(HIERA_FILE) else $node = {"services" => [], "dummy" => true} end # load all test classes this_file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ - Dir[File.expand_path('../../tests/helpers/*.rb', this_file)].each do |helper| - require helper + HELPER_PATHS.each do |path| + Dir[File.expand_path(path, this_file)].each do |helper| + require helper + end end - Dir[File.expand_path('../../tests/white-box/*.rb', this_file)].each do |test_file| - begin - require test_file - rescue SkipTest + TEST_PATHS.each do |path| + Dir[File.expand_path(path, this_file)].each do |test_file| + begin + require test_file + rescue SkipTest + end end end -- cgit v1.2.3