Skip to content

Commit

Permalink
Initial implementation of only_include
Browse files Browse the repository at this point in the history
  • Loading branch information
Hook25 committed Aug 16, 2024
1 parent c1dccf8 commit d348a70
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions checkbox-ng/plainbox/impl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ class DynamicSection(dict):
"exclude": VarSpec(
list, [], "Exclude test matching patterns from running."
),
"only_include": VarSpec(
list, [], "Only run job that match or their dependencies."
)
},
),
(
Expand Down
26 changes: 25 additions & 1 deletion checkbox-ng/plainbox/impl/session/assistant.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# This file is part of Checkbox.
#
# Copyright 2012-2023 Canonical Ltd.
# Copyright 2012-2024 Canonical Ltd.
# Written by:
# Zygmunt Krynicki <[email protected]>
# Maciej Kisielewski <[email protected]>
# Massimiliano Girardi <[email protected]>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
Expand Down Expand Up @@ -181,6 +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._manager = None
self._context = None
self._metadata = None
Expand Down Expand Up @@ -335,6 +337,14 @@ def use_alternate_configuration(self, config):
self._exclude_qualifiers.append(
RegExpJobQualifier(pattern, None, False)
)

self._only_include_qualifiers = []

Check warning on line 341 in checkbox-ng/plainbox/impl/session/assistant.py

View check run for this annotation

Codecov / codecov/patch

checkbox-ng/plainbox/impl/session/assistant.py#L341

Added line #L341 was not covered by tests
for pattern in self._config.get_value(
"test selection", "only_include"
):
self._only_include_qualifiers.append(

Check warning on line 345 in checkbox-ng/plainbox/impl/session/assistant.py

View check run for this annotation

Codecov / codecov/patch

checkbox-ng/plainbox/impl/session/assistant.py#L345

Added line #L345 was not covered by tests
RegExpJobQualifier(pattern, None, True)
)
Unit.config = config
# NOTE: We expect applications to call this at most once.
del UsageExpectation.of(self).allowed_calls[
Expand Down Expand Up @@ -935,6 +945,20 @@ def finish_bootstrap(self):
)
],
)
if self._only_include_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(

Check warning on line 951 in checkbox-ng/plainbox/impl/session/assistant.py

View check run for this annotation

Codecov / codecov/patch

checkbox-ng/plainbox/impl/session/assistant.py#L951

Added line #L951 was not covered by tests
desired_job_list,
self._only_include_qualifiers
+ self._exclude_qualifiers
+ [
JobIdQualifier(
"com.canonical.plainbox::collect-manifest", None, False
)
],
)

self._context.state.update_desired_job_list(desired_job_list)
# Set subsequent usage expectations i.e. all of the runtime parts are
# available now.
Expand Down

0 comments on commit d348a70

Please sign in to comment.