From 8b95b2a8551909d5f1eabfe146eb256d804ff036 Mon Sep 17 00:00:00 2001 From: beergeek Date: Fri, 11 May 2018 22:28:39 +1000 Subject: [PATCH] Check Node/Classes hashes This update checks the Node and Classes nodes contians an `exclude` if `include` is in the hash. This allows a fail-early scenario. --- lib/onceover/testconfig.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/onceover/testconfig.rb b/lib/onceover/testconfig.rb index 49758f96..485a3fe9 100644 --- a/lib/onceover/testconfig.rb +++ b/lib/onceover/testconfig.rb @@ -126,9 +126,13 @@ def self.subtractive_to_list(subtractive_hash) # { 'include' => 'somegroup' # 'exclude' => 'other'} # and return a list of classes/nodes - include_list = Onceover::TestConfig.find_list(subtractive_hash['include']).flatten - exclude_list = Onceover::TestConfig.find_list(subtractive_hash['exclude']).flatten - include_list - exclude_list + if subtractive_hash.has_key?('include') && subtractive_hash.has_key?('exclude') + include_list = Onceover::TestConfig.find_list(subtractive_hash['include']).flatten + exclude_list = Onceover::TestConfig.find_list(subtractive_hash['exclude']).flatten + include_list - exclude_list + else + raise "The classes/nodes hash must have an `exclude` if using an `include`" + end end def verify_spec_test(controlrepo, test)