Module: GitlabQuality::TestTooling::TestQuarantine::QuarantineHelper
- Extended by:
- QuarantineHelper
- Includes:
- RSpec::Core::Pending
- Included in:
- QuarantineFormatter, QuarantineHelper
- Defined in:
- lib/gitlab_quality/test_tooling/test_quarantine/quarantine_helper.rb
Instance Method Summary collapse
- #filters ⇒ Object
- #filters_other_than_quarantine ⇒ Object
- #quarantine_message(quarantine_tag) ⇒ Object
-
#should_skip_when_focused?(metadata, included_filters) ⇒ Boolean
Checks if a test or context should be skipped.
-
#skip_or_run_quarantined_tests_or_contexts(example) ⇒ Object
Skip tests in quarantine unless we explicitly focus on them or quarantine disabled.
Instance Method Details
#filters ⇒ Object
70 71 72 |
# File 'lib/gitlab_quality/test_tooling/test_quarantine/quarantine_helper.rb', line 70 def filters @filters ||= ::RSpec.configuration.inclusion_filter.rules end |
#filters_other_than_quarantine ⇒ Object
38 39 40 |
# File 'lib/gitlab_quality/test_tooling/test_quarantine/quarantine_helper.rb', line 38 def filters_other_than_quarantine filters.except(:quarantine) end |
#quarantine_message(quarantine_tag) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gitlab_quality/test_tooling/test_quarantine/quarantine_helper.rb', line 42 def (quarantine_tag) = %w[In quarantine] << case quarantine_tag when String ": #{quarantine_tag}" when Hash quarantine_tag.key?(:issue) ? ": #{quarantine_tag[:issue]}" : '' else '' end .join(' ').strip end |
#should_skip_when_focused?(metadata, included_filters) ⇒ Boolean
Checks if a test or context should be skipped.
Returns true if
-
the metadata does not includes the :quarantine tag
or if
-
the metadata includes the :quarantine tag
-
and the filter includes other tags that aren’t in the metadata
63 64 65 66 67 68 |
# File 'lib/gitlab_quality/test_tooling/test_quarantine/quarantine_helper.rb', line 63 def should_skip_when_focused?(, included_filters) return true unless .key?(:quarantine) return false if included_filters.empty? !.keys.intersect?(included_filters.keys) end |
#skip_or_run_quarantined_tests_or_contexts(example) ⇒ Object
Skip tests in quarantine unless we explicitly focus on them or quarantine disabled
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gitlab_quality/test_tooling/test_quarantine/quarantine_helper.rb', line 14 def skip_or_run_quarantined_tests_or_contexts(example) return if Runtime::Env.quarantine_disabled? if filters.key?(:quarantine) included_filters = filters_other_than_quarantine # If :quarantine is focused, skip the test/context unless its metadata # includes quarantine and any other filters # E.g., Suppose a test is tagged :smoke and :quarantine, and another is tagged # :ldap and :quarantine. If we wanted to run just quarantined smoke tests # using `--tag quarantine --tag smoke`, without this check we'd end up # running that ldap test as well because of the :quarantine metadata. # We could use an exclusion filter, but this way the test report will list # the quarantined tests when they're not run so that we're aware of them if should_skip_when_focused?(example., included_filters) example.[:skip] = "Only running tests tagged with :quarantine and any of #{included_filters.keys}" end elsif example..key?(:quarantine) quarantine_tag = example.[:quarantine] example.[:skip] = (quarantine_tag) end end |