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)