diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /tooling/quality | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'tooling/quality')
-rw-r--r-- | tooling/quality/test_level.rb | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tooling/quality/test_level.rb b/tooling/quality/test_level.rb index ad9de067375..83cbe7a1f19 100644 --- a/tooling/quality/test_level.rb +++ b/tooling/quality/test_level.rb @@ -60,20 +60,20 @@ module Quality system: ['features'] }.freeze - attr_reader :prefix + attr_reader :prefixes - def initialize(prefix = nil) - @prefix = prefix + def initialize(prefixes = nil) + @prefixes = Array(prefixes) @patterns = {} @regexps = {} end def pattern(level) - @patterns[level] ||= "#{prefix}spec/#{folders_pattern(level)}{,/**/}*#{suffix(level)}" + @patterns[level] ||= "#{prefixes_for_pattern}spec/#{folders_pattern(level)}{,/**/}*#{suffix(level)}" end def regexp(level) - @regexps[level] ||= Regexp.new("#{prefix}spec/#{folders_regex(level)}").freeze + @regexps[level] ||= Regexp.new("#{prefixes_for_regex}spec/#{folders_regex(level)}").freeze end def level_for(file_path) @@ -102,6 +102,20 @@ module Quality private + def prefixes_for_pattern + return '' if prefixes.empty? + + "{#{prefixes.join(',')}}" + end + + def prefixes_for_regex + return '' if prefixes.empty? + + regex_prefix = prefixes.map(&Regexp.method(:escape)).join('|') + + "(#{regex_prefix})" + end + def suffix(level) case level when :frontend_fixture |