diff --git a/tmt/steps/execute/__init__.py b/tmt/steps/execute/__init__.py index 21bd4cd929..c941da813b 100644 --- a/tmt/steps/execute/__init__.py +++ b/tmt/steps/execute/__init__.py @@ -232,6 +232,11 @@ def reboot_request_path(self) -> Path: """ A path to the reboot request file """ return self.test_data_path / TMT_REBOOT_SCRIPT.created_file + @functools.cached_property + def abort_request_path(self) -> Path: + """ A path to the abort request file """ + return self.test_data_path / TMT_ABORT_SCRIPT.created_file + @property def soft_reboot_requested(self) -> bool: """ If set, test requested a reboot """ @@ -252,6 +257,12 @@ def restart_requested(self) -> bool: return self.return_code in self.test.restart_on_exit_code + @property + def abort_requested(self) -> bool: + """ Whether a testing abort was requested """ + + return self.abort_request_path.exists() + @property def is_guest_healthy(self) -> bool: """ @@ -701,14 +712,6 @@ def extract_results( return invocation.test.test_framework.extract_results(invocation, logger) - def check_abort_file(self, invocation: TestInvocation) -> bool: - """ - Check for an abort file created by tmt-abort - - Returns whether an abort file is present (i.e. abort occurred). - """ - return (invocation.test_data_path / TMT_ABORT_SCRIPT.created_file).exists() - @staticmethod def format_timestamp(timestamp: datetime.datetime) -> str: """ Convert timestamp to a human readable format """ diff --git a/tmt/steps/execute/internal.py b/tmt/steps/execute/internal.py index e7f13b5dca..e501be7b18 100644 --- a/tmt/steps/execute/internal.py +++ b/tmt/steps/execute/internal.py @@ -571,11 +571,12 @@ def _run_tests( for result in invocation.results: result.result = ResultOutcome.ERROR result.note = 'reboot timeout' - abort = self.check_abort_file(invocation) - if abort: + + if invocation.abort_requested: for result in invocation.results: # In case of aborted all results in list will be aborted result.note = 'aborted' + self._results.extend(invocation.results) # If test duration information is missing, print 8 spaces to keep indentation @@ -597,11 +598,14 @@ def _format_duration(result: BaseResult) -> str: f'({check_result.event.value} check)', shift=shift) - if (abort or self.data.exit_first and - result.result not in (ResultOutcome.PASS, ResultOutcome.INFO)): + if invocation.abort_requested or ( + self.data.exit_first and any( + result.result not in ( + ResultOutcome.PASS, + ResultOutcome.INFO) for result in invocation.results)): # Clear the progress bar before outputting progress_bar.clear() - what_happened = "aborted" if abort else "failed" + what_happened = "aborted" if invocation.abort_requested else "failed" self.warn( f'Test {test.name} {what_happened}, stopping execution.') break