Skip to content

Commit

Permalink
Feature/exit status (#5)
Browse files Browse the repository at this point in the history
* return status of scenario as final result

* add note to changelog

---------

Co-authored-by: Benedikt Haas <[email protected]>
  • Loading branch information
BenediktHaas96 and Benedikt Haas authored Feb 5, 2024
1 parent 6f08e0f commit d2a800b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CARLOS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions scenario_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -427,16 +429,14 @@ 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()
if self._args.record:
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)
Expand Down

0 comments on commit d2a800b

Please sign in to comment.