diff options
author | elijah <elijah@riseup.net> | 2015-01-22 14:11:15 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2015-01-22 14:11:15 -0800 |
commit | 19567504f45a1041a088a8b91e1eb323583661f5 (patch) | |
tree | 9ff5ec6b19e4c3844e16944cc15eaf15815f4ffe /bin | |
parent | 0d46876a37334e71634eeaa77546d3fa5d1fde55 (diff) |
added support for custom tests in files/tests
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/run_tests | 40 |
1 files changed, 27 insertions, 13 deletions
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 |