From d2a800b084ae166da5ab993da98fa92cd79a09a6 Mon Sep 17 00:00:00 2001 From: Benedikt Haas <45701381+BenediktHaas96@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:15:48 +0100 Subject: [PATCH] Feature/exit status (#5) * return status of scenario as final result * add note to changelog --------- Co-authored-by: Benedikt Haas --- CARLOS_CHANGELOG.md | 1 + scenario_runner.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CARLOS_CHANGELOG.md b/CARLOS_CHANGELOG.md index 361487ae5..598ac5dd4 100644 --- a/CARLOS_CHANGELOG.md +++ b/CARLOS_CHANGELOG.md @@ -11,3 +11,4 @@ ### Minor changes * Small fix related to CARLA autopilot +* Modified `scenario_runner.py` to return the result of scenario execution as exit code diff --git a/scenario_runner.py b/scenario_runner.py index 18ac73147..ffe12bef3 100755 --- a/scenario_runner.py +++ b/scenario_runner.py @@ -270,10 +270,12 @@ def _analyze_scenario(self, config): if not self.manager.analyze_scenario(self._args.output, filename, junit_filename, json_filename): print("All scenario tests were passed successfully!") + return True else: print("Not all scenario tests were successful") if not (self._args.output or filename or junit_filename): print("Please run with --output for further information") + return False def _record_criteria(self, criteria, name): """ @@ -427,7 +429,7 @@ def _load_and_run_scenario(self, config): self.manager.run_scenario() # Provide outputs if required - self._analyze_scenario(config) + result = self._analyze_scenario(config) # Remove all actors, stop the recorder and save all criterias (if needed) scenario.remove_all_actors() @@ -435,8 +437,6 @@ def _load_and_run_scenario(self, config): self.client.stop_recorder() self._record_criteria(self.manager.scenario.get_criteria(), recorder_name) - result = True - except Exception as e: # pylint: disable=broad-except traceback.print_exc() print(e)