twister: improve handling of artifacts with --prep-artifacts-for-testing
Previous commit dealing with cleanup (c304db56f1d) was not taking
prep-artifacts-for-testing into consideration. Fix this and make sure
we do cleanup when this option is enabled.
@@ -578,20 +578,18 @@ class ProjectBuilder(FilterBuilder):
self.report_out(results)
if not self.options.coverage:
- if self.options.runtime_artifact_cleanup == "pass" and self.instance.status == "passed":
- pipeline.put({"op": "cleanup_pass", "test": self.instance})
- if self.options.runtime_artifact_cleanup == "all":
- pipeline.put({"op": "cleanup_all", "test": self.instance})
-
- elif op == "cleanup_pass":
- if self.options.device_testing or self.options.prep_artifacts_for_testing:
+ if self.options.prep_artifacts_for_testing:
+ pipeline.put({"op": "cleanup", "mode": "device", "test": self.instance})
+ elif self.options.runtime_artifact_cleanup == "pass" and self.instance.status == "passed":
+ pipeline.put({"op": "cleanup", "mode": "passed", "test": self.instance})
+ elif self.options.runtime_artifact_cleanup == "all":
+ pipeline.put({"op": "cleanup", "mode": "all", "test": self.instance})
+
+ elif op == "cleanup":
+ mode = message.get("mode")
+ if mode == "device":
self.cleanup_device_testing_artifacts()
- else:
- self.cleanup_artifacts()
- elif op == "cleanup_all":
- if (self.options.device_testing or self.options.prep_artifacts_for_testing) and self.instance.reason != "Cmake build failure":
- self.cleanup_device_testing_artifacts()
- else:
+ elif mode == "pass" or (mode == "all" and self.instance.reason != "Cmake build failure"):
self.cleanup_artifacts()
def determine_testcases(self, results):
