From 798c85b493650fb8e199aa2212b6f82addca88b4 Mon Sep 17 00:00:00 2001 From: Hook25 Date: Mon, 19 Aug 2024 14:21:39 +0200 Subject: [PATCH] Rename only_include to match --- checkbox-ng/plainbox/impl/config.py | 2 +- .../plainbox/impl/session/assistant.py | 12 +++++----- .../plainbox/impl/session/test_assistant.py | 16 ++++++------- docs/reference/launcher.rst | 8 +++---- ...un-test-units.pxu => match-test-units.pxu} | 24 +++++++++---------- .../config/{only_include.py => match.py} | 20 ++++++++-------- 6 files changed, 41 insertions(+), 41 deletions(-) rename metabox/metabox/metabox-provider/units/{only-run-test-units.pxu => match-test-units.pxu} (78%) rename metabox/metabox/scenarios/config/{only_include.py => match.py} (80%) diff --git a/checkbox-ng/plainbox/impl/config.py b/checkbox-ng/plainbox/impl/config.py index c9dad5f518..3cd3cf1063 100644 --- a/checkbox-ng/plainbox/impl/config.py +++ b/checkbox-ng/plainbox/impl/config.py @@ -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." ), }, diff --git a/checkbox-ng/plainbox/impl/session/assistant.py b/checkbox-ng/plainbox/impl/session/assistant.py index bf20ff8184..3a6d2015bb 100644 --- a/checkbox-ng/plainbox/impl/session/assistant.py +++ b/checkbox-ng/plainbox/impl/session/assistant.py @@ -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 @@ -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 @@ -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( diff --git a/checkbox-ng/plainbox/impl/session/test_assistant.py b/checkbox-ng/plainbox/impl/session/test_assistant.py index 03d8eef115..4aca94daed 100644 --- a/checkbox-ng/plainbox/impl/session/test_assistant.py +++ b/checkbox-ng/plainbox/impl/session/test_assistant.py @@ -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," @@ -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) diff --git a/docs/reference/launcher.rst b/docs/reference/launcher.rst index e6e29252de..124f6adf28 100644 --- a/docs/reference/launcher.rst +++ b/docs/reference/launcher.rst @@ -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 @@ -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: diff --git a/metabox/metabox/metabox-provider/units/only-run-test-units.pxu b/metabox/metabox/metabox-provider/units/match-test-units.pxu similarity index 78% rename from metabox/metabox/metabox-provider/units/only-run-test-units.pxu rename to metabox/metabox/metabox-provider/units/match-test-units.pxu index 56a0a99f04..f650d32234 100644 --- a/metabox/metabox/metabox-provider/units/only-run-test-units.pxu +++ b/metabox/metabox/metabox-provider/units/match-test-units.pxu @@ -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 @@ -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: @@ -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 @@ -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: diff --git a/metabox/metabox/scenarios/config/only_include.py b/metabox/metabox/scenarios/config/match.py similarity index 80% rename from metabox/metabox/scenarios/config/only_include.py rename to metabox/metabox/scenarios/config/match.py index 14a7b72c90..4ba5b012fd 100644 --- a/metabox/metabox/scenarios/config/only_include.py +++ b/metabox/metabox/scenarios/config/match.py @@ -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( @@ -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( @@ -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 = [