Refactor package_outputs
Refactor package_outputs in the TestOptimizer so it just returns a list
of soong_zip commands to be run by build_test_suites.
Since we already have a tested implementation for running subprocesses
in build_test_suites.py there's no reason to reimplement it in
optimized_targets.py. Because any packaging will ultimately use
soong_zip to package its final outputs change the code to just do
whatever prep it needs to and return a list of soong_zip commands.
This way the code is simpler to test without requiring subprocesses and
no reimplementation of subprocess running code is necessary.
Test: atest build_test_suites_test; atest optimized_targets_test
Bug: 358215235
Change-Id: I3025aefeeb7186f537266a72d8422211ca9835ba
diff --git a/ci/optimized_targets.py b/ci/optimized_targets.py
index fddde17..9143cbf 100644
--- a/ci/optimized_targets.py
+++ b/ci/optimized_targets.py
@@ -52,14 +52,17 @@
self.modules_to_build = {self.target}
return {self.target}
- def package_outputs(self):
+ def get_package_outputs_commands(self) -> list[list[str]]:
features = self.build_context.enabled_build_features
if self.get_enabled_flag() in features:
- return self.package_outputs_impl()
+ return self.get_package_outputs_commands_impl()
- def package_outputs_impl(self):
+ return []
+
+ def get_package_outputs_commands_impl(self) -> list[list[str]]:
raise NotImplementedError(
- f'package_outputs_impl not implemented in {type(self).__name__}'
+ 'get_package_outputs_commands_impl not implemented in'
+ f' {type(self).__name__}'
)
def get_enabled_flag(self):
@@ -86,8 +89,8 @@
def get_build_targets(self):
return {self.target}
- def package_outputs(self):
- pass
+ def get_package_outputs_commands(self):
+ return []
class ChangeInfo:
@@ -114,6 +117,7 @@
return changed_files
+
class GeneralTestsOptimizer(OptimizedBuildTarget):
"""general-tests optimizer