Skip to content

Commit

Permalink
Rename only_include to match
Browse files Browse the repository at this point in the history
  • Loading branch information
Hook25 committed Aug 19, 2024
1 parent 56682de commit 798c85b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion checkbox-ng/plainbox/impl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class DynamicSection(dict):
"exclude": VarSpec(
list, [], "Exclude test matching patterns from running."
),
"only_include": VarSpec(
"match": VarSpec(
list, [], "Only run job that match or their dependencies."
),
},
Expand Down
12 changes: 6 additions & 6 deletions checkbox-ng/plainbox/impl/session/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(
# manager matters, the context and metadata are just shortcuts to stuff
# available on the manager.
self._exclude_qualifiers = []
self._only_include_qualifiers = []
self._match_qualifiers = []
self._manager = None
self._context = None
self._metadata = None
Expand Down Expand Up @@ -338,11 +338,11 @@ def use_alternate_configuration(self, config):
RegExpJobQualifier(pattern, None, False)
)

self._only_include_qualifiers = []
self._match_qualifiers = []
for pattern in self._config.get_value(
"test selection", "only_include"
"test selection", "match"
):
self._only_include_qualifiers.append(
self._match_qualifiers.append(
RegExpJobQualifier(pattern, None, True)
)
Unit.config = config
Expand Down Expand Up @@ -945,12 +945,12 @@ def finish_bootstrap(self):
)
],
)
if self._only_include_qualifiers:
if self._match_qualifiers:
# when only include is provided, use the testplan but prune it to
# only pull the jobs asked in the launcher or their dependencies
desired_job_list = select_units(
desired_job_list,
self._only_include_qualifiers
self._match_qualifiers
+ self._exclude_qualifiers
+ [
JobIdQualifier(
Expand Down
16 changes: 8 additions & 8 deletions checkbox-ng/plainbox/impl/session/test_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_use_alternate_configuration(self, ue_mock, mock_get_providers):
def get_value(section, value):
if section == "test selection" and value == "exclude":
return [r".*some.*", r".*other.*"]
elif section == "test selection" and value == "only_include":
elif section == "test selection" and value == "match":
return [r".*target", r".*another_target"]
raise AssertionError(
"Need more configuration sections/config to mock,"
Expand All @@ -245,34 +245,34 @@ def get_value(section, value):
SessionAssistant.use_alternate_configuration(self_mock, config_mock)

self.assertEqual(len(self_mock._exclude_qualifiers), 2)
self.assertEqual(len(self_mock._only_include_qualifiers), 2)
self.assertEqual(len(self_mock._match_qualifiers), 2)

@mock.patch("plainbox.impl.session.assistant.UsageExpectation")
@mock.patch("plainbox.impl.session.assistant.select_units")
def test_finish_bootstrap_only_include_nominal(
def test_finish_bootstrap_match_nominal(
self, select_units_mock, ue_mock, get_providers_mock
):
self_mock = mock.MagicMock()
# this is just to test that the subfunction is called if this arr is
# defined, assumes the select_units function is mocked
self_mock._only_include_qualifiers = [1, 2, 3]
self_mock._match_qualifiers = [1, 2, 3]

SessionAssistant.finish_bootstrap(self_mock)

# called once to get all the jobs for the selected testplan
# and another time to prune it for only_include
# and another time to prune it for match`
self.assertEqual(select_units_mock.call_count, 2)

@mock.patch("plainbox.impl.session.assistant.UsageExpectation")
@mock.patch("plainbox.impl.session.assistant.select_units")
def test_finish_bootstrap_only_include_no_only_include(
def test_finish_bootstrap_match_no_match(
self, select_units_mock, ue_mock, get_providers_mock
):
self_mock = mock.MagicMock()
self_mock._only_include_qualifiers = []
self_mock._match_qualifiers = []

SessionAssistant.finish_bootstrap(self_mock)

# called once to get all the jobs for the selected testplan
# and another time to prune it for only_include
# and another time to prune it for match
self.assertEqual(select_units_mock.call_count, 1)
8 changes: 4 additions & 4 deletions docs/reference/launcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Note: To clear the exclude list use...

...in your 'last' config.

``only_include``
``match``
List of regex patterns that job ids will be matched against. Checkbox will
only run the matching jobs, their dependencies and any job included in the
testplan bootstrap section. This is useful to re-run the failing subset of
Expand All @@ -219,13 +219,13 @@ Only run ``bluetooth`` jobs and their dependencies:
.. code-block:: ini
[test selection]
only_include = .*bluetooth.*
match = .*bluetooth.*
.. note::
``exclude`` takes precedence over ``only_include``.
``exclude`` takes precedence over ``match``.

.. note::
You can use ``only_include`` only to select jobs already included in a test
You can use ``match`` only to select jobs already included in a test
plan. You can not use it to include additional tests in a test plan.

.. _launcher_ui:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ depends:
command: true

id: nested_target
_summary: Used to test that the only_include target can be in a nested part
_summary: Used to test that the match target can be in a nested part
flags: simple
depends:
nested_direct_dependency
command: true

id: nested_not_included
_summary: Used to test that tests not in only_include aren't pulled in nested part
_summary: Used to test that tests not in match aren't pulled in nested part
flags: simple
command: false

id: nested_exclude_target
_summary: Used to test that exclude has the precedence over only_include for nested part
_summary: Used to test that exclude has the precedence over match for nested part
flags: simple
command: false

Expand All @@ -51,12 +51,12 @@ template-unit: job
id: nested_generated_job_template_{nested_direct_resource}
template-id: nested_include_by_template_id
flags: simple
_summary: Used to test that template-id is used to only_include from nested part
_summary: Used to test that template-id is used to match from nested part
command: true

unit: test plan
id: nested_part_tests
_name: Test plan used as a nested_part by the only_include tp
_name: Test plan used as a nested_part by the match tp
bootstrap_include:
nested_indirect_resource
include:
Expand Down Expand Up @@ -100,24 +100,24 @@ depends:
command: true

id: include_target
_summary: Used to test that the only_include target can be in a include
_summary: Used to test that the match target can be in a include
flags: simple
depends:
include_direct_dependency
command: true

id: include_not_included
_summary: Used to test that tests not in only_include aren't pulled in include
_summary: Used to test that tests not in match aren't pulled in include
flags: simple
command: false

id: include_exclude_target
_summary: Used to test that exclude has the precedence over only_include for include
_summary: Used to test that exclude has the precedence over match for include
flags: simple
command: false

id: include_launcher_removed_target
_summary: Used to test that exclude has precedence over only_include from launcher as well
_summary: Used to test that exclude has precedence over match from launcher as well
flags: simple
command: false

Expand All @@ -127,14 +127,14 @@ template-unit: job
id: include_generated_job_template_{include_direct_resource}
template-id: include_include_by_template_id
flags: simple
_summary: Used to test that template-id is used to only_include from include
_summary: Used to test that template-id is used to match from include
command: true

# test plan differs in exclude constraint and nested_part

unit: test plan
id: stress_only_include
_name: Test plan used as a include_part by the only_include tp
id: stress_match
_name: Test plan used as a include_part by the match tp
bootstrap_include:
include_indirect_resource
include:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
from metabox.core.scenario import Scenario


@tag("test_selection", "only_include", "return_code")
class TestSelectionOnlyIncludeEmpty(Scenario):
@tag("test_selection", "match", "return_code")
class TestSelectionMatchEmpty(Scenario):
"""
Try to only_include a test that is not in the test plan, nothing should run
Try to match a test that is not in the test plan, nothing should run
"""

launcher = textwrap.dedent(
Expand All @@ -43,17 +43,17 @@ class TestSelectionOnlyIncludeEmpty(Scenario):
forced = yes
[test selection]
forced = yes
only_include = .*storage-preinserted.*
match = .*storage-preinserted.*
"""
)
steps = [Start(), AssertRetCode(1)]


@tag("test_selection", "only_include", "return_code")
class TestSelectionOnlyIncludeNominal(Scenario):
@tag("test_selection", "match", "return_code")
class TestSelectionMatchNominal(Scenario):
"""
only_include only pulls jobs and their direct/indirect dependencies +
all bootstrap jobs. exclude has the precedence over only_include
match only pulls jobs and their direct/indirect dependencies +
all bootstrap jobs. exclude has the precedence over match
"""

launcher = textwrap.dedent(
Expand All @@ -63,12 +63,12 @@ class TestSelectionOnlyIncludeNominal(Scenario):
launcher_version = 1
stock_reports = text
[test plan]
unit = 2021.com.canonical.certification::stress_only_include
unit = 2021.com.canonical.certification::stress_match
forced = yes
[test selection]
forced = yes
exclude = .*launcher_removed_target
only_include = .*target
match = .*target
"""
)
steps = [
Expand Down

0 comments on commit 798c85b

Please sign in to comment.