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
This commit is contained in:
@@ -52,14 +52,17 @@ class OptimizedBuildTarget(ABC):
|
||||
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 @@ class NullOptimizer(OptimizedBuildTarget):
|
||||
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 @@ class ChangeInfo:
|
||||
|
||||
return changed_files
|
||||
|
||||
|
||||
class GeneralTestsOptimizer(OptimizedBuildTarget):
|
||||
"""general-tests optimizer
|
||||
|
||||
|
Reference in New Issue
Block a user