summaryrefslogtreecommitdiff
path: root/qa/qa/specs/helpers/quarantine.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
commitedaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch)
tree11f143effbfeba52329fb7afbd05e6e2a3790241 /qa/qa/specs/helpers/quarantine.rb
parentd8a5691316400a0f7ec4f83832698f1988eb27c1 (diff)
downloadgitlab-ce-edaa33dee2ff2f7ea3fac488d41558eb5f86d68c.tar.gz
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'qa/qa/specs/helpers/quarantine.rb')
-rw-r--r--qa/qa/specs/helpers/quarantine.rb25
1 files changed, 16 insertions, 9 deletions
diff --git a/qa/qa/specs/helpers/quarantine.rb b/qa/qa/specs/helpers/quarantine.rb
index 49d91fc87cd..738c99efb28 100644
--- a/qa/qa/specs/helpers/quarantine.rb
+++ b/qa/qa/specs/helpers/quarantine.rb
@@ -11,9 +11,9 @@ module QA
extend self
# Skip tests in quarantine unless we explicitly focus on them.
- def skip_or_run_quarantined_tests_or_contexts(filters, example)
+ def skip_or_run_quarantined_tests_or_contexts(example)
if filters.key?(:quarantine)
- included_filters = filters_other_than_quarantine(filters)
+ included_filters = filters_other_than_quarantine
# If :quarantine is focused, skip the test/context unless its metadata
# includes quarantine and any other filters
@@ -29,18 +29,17 @@ module QA
elsif example.metadata.key?(:quarantine)
quarantine_tag = example.metadata[:quarantine]
- if quarantine_tag.is_a?(Hash) && quarantine_tag&.key?(:only) && !ContextSelector.context_matches?(quarantine_tag[:only])
- # If the :quarantine hash contains :only, we respect that.
- # For instance `quarantine: { only: { subdomain: :staging } }` will only quarantine the test when it runs against staging.
- return
- end
+ # If the :quarantine hash contains :only, we respect that.
+ # For instance `quarantine: { only: { subdomain: :staging } }`
+ # will only quarantine the test when it runs against staging.
+ return if quarantined_different_context?(quarantine_tag)
example.metadata[:skip] = quarantine_message(quarantine_tag)
end
end
- def filters_other_than_quarantine(filter)
- filter.reject { |key, _| key == :quarantine }
+ def filters_other_than_quarantine
+ filters.reject { |key, _| key == :quarantine }
end
def quarantine_message(quarantine_tag)
@@ -70,6 +69,14 @@ module QA
(metadata.keys & included_filters.keys).empty?
end
+
+ def quarantined_different_context?(quarantine)
+ quarantine.is_a?(Hash) && quarantine.key?(:only) && !ContextSelector.context_matches?(quarantine[:only])
+ end
+
+ def filters
+ @filters ||= ::RSpec.configuration.inclusion_filter.rules
+ end
end
end
end