From 9dae735a8430dc4535865b5e9b3e616989a74882 Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Fri, 24 Sep 2021 10:31:49 +0200 Subject: [PATCH] Testsuite: update after --disable-cleanup removal in e3-testsuite (cherry picked from commit cd76dd9d5633e0a279bdcc29c649d7da971bd0dc) TN: U920-044 Change-Id: If53103dde319aa7196374dcb523a9642a79ff4f4 --- testsuite/drivers/data_validation.py | 39 ++++++++++++++++------------ testsuite/run-tests | 1 - 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/testsuite/drivers/data_validation.py b/testsuite/drivers/data_validation.py index be5f2d81..43a5f1fa 100644 --- a/testsuite/drivers/data_validation.py +++ b/testsuite/drivers/data_validation.py @@ -1,5 +1,6 @@ from e3.fs import rm from e3.testsuite.result import TestStatus, TestResult +from e3.testsuite.utils import CleanupMode from drivers import GNATcollTestDriver, gprbuild import os @@ -55,22 +56,28 @@ def validate_result(self, process, data_file, result): return True def tear_down(self, previous_values, slot): - # If the test program build failed, there is nothing we can do (and the - # result for this test is alredy pushed anyway). - if not previous_values.get('build'): - return False - - failures = [v for v in previous_values.values() if - not isinstance(v, TestStatus) or v != TestStatus.PASS] - if failures: - self.result.set_status(TestStatus.FAIL, - msg="%s subtests failed" % len(failures)) - else: - self.result.set_status(TestStatus.PASS) - - self.push_result() - - if self.env.enable_cleanup: + # If the build failed in the "build" fragment, we already pushed the + # result. + failed = True + if previous_values.get('build'): + failures = [v for v in previous_values.values() if + not isinstance(v, TestStatus) or v != TestStatus.PASS] + if failures: + self.result.set_status( + TestStatus.FAIL, + msg="%s subtests failed" % len(failures) + ) + else: + failed = False + self.result.set_status(TestStatus.PASS) + + self.push_result() + + # Cleanup temporaries if requested + if ( + self.env.cleanup_mode == CleanupMode.ALL + or (self.env.cleanup_mode == CleanupMode.PASSING and not failed) + ): rm(self.test_env['working_dir'], recursive=True) def build(self, previous_values, slot): diff --git a/testsuite/run-tests b/testsuite/run-tests index 6907834b..cd1fc25d 100755 --- a/testsuite/run-tests +++ b/testsuite/run-tests @@ -49,7 +49,6 @@ class MyTestsuite(Testsuite): self.env.gcov = self.main.args.gcov self.env.gnatcov = self.main.args.gnatcov self.env.valgrind = self.main.args.valgrind - self.env.enable_cleanup = self.main.args.enable_cleanup # Reject incompatible options incompatible = [name for name in ('gcov', 'gnatcov', 'valgrind')