diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-27 18:06:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-27 18:06:16 +0300 |
commit | 8320f7956d72986f5a7c850874fce4f8b5a8e015 (patch) | |
tree | c761b309cfff422609d47a17ac4d6a732c142f49 /lib/quality | |
parent | 45482d5a2704da7fabe4ccf07f85d9be6e0a791a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/quality')
-rw-r--r-- | lib/quality/test_level.rb | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/quality/test_level.rb b/lib/quality/test_level.rb index a65657dadd0..b7822adf6ed 100644 --- a/lib/quality/test_level.rb +++ b/lib/quality/test_level.rb @@ -53,11 +53,11 @@ module Quality end def pattern(level) - @patterns[level] ||= "#{prefix}spec/{#{TEST_LEVEL_FOLDERS.fetch(level).join(',')}}{,/**/}*_spec.rb" + @patterns[level] ||= "#{prefix}spec/#{folders_pattern(level)}{,/**/}*_spec.rb" end def regexp(level) - @regexps[level] ||= Regexp.new("#{prefix}spec/(#{TEST_LEVEL_FOLDERS.fetch(level).join('|')})").freeze + @regexps[level] ||= Regexp.new("#{prefix}spec/#{folders_regex(level)}").freeze end def level_for(file_path) @@ -72,5 +72,27 @@ module Quality raise UnknownTestLevelError, "Test level for #{file_path} couldn't be set. Please rename the file properly or change the test level detection regexes in #{__FILE__}." end end + + private + + def folders_pattern(level) + case level + # Geo specs aren't in a specific folder, but they all have the :geo tag, so we must search for them globally + when :all, :geo + '**' + else + "{#{TEST_LEVEL_FOLDERS.fetch(level).join(',')}}" + end + end + + def folders_regex(level) + case level + # Geo specs aren't in a specific folder, but they all have the :geo tag, so we must search for them globally + when :all, :geo + '' + else + "(#{TEST_LEVEL_FOLDERS.fetch(level).join('|')})" + end + end end end |