-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of only_include
- Loading branch information
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
|
@@ -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 | ||
|
@@ -335,6 +337,14 @@ def use_alternate_configuration(self, config): | |
self._exclude_qualifiers.append( | ||
RegExpJobQualifier(pattern, None, False) | ||
) | ||
|
||
self._only_include_qualifiers = [] | ||
for pattern in self._config.get_value( | ||
"test selection", "only_include" | ||
): | ||
self._only_include_qualifiers.append( | ||
RegExpJobQualifier(pattern, None, True) | ||
) | ||
Unit.config = config | ||
# NOTE: We expect applications to call this at most once. | ||
del UsageExpectation.of(self).allowed_calls[ | ||
|
@@ -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( | ||
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. | ||
|