Commit 386a87eb authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

In "run_vadere_console_with_all_scenario_files.py", run ALL scenario files,...

In "run_vadere_console_with_all_scenario_files.py", run ALL scenario files, catch exceptions and log exceptions.

Exit with return code 1 if at least one test failed. Otherwise, return 0.
parent af25b04e
Pipeline #64378 failed with stages
in 44 minutes and 27 seconds
......@@ -44,27 +44,49 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
total_scenario_files = len(scenario_files)
for i, scenario_file in enumerate(scenario_files):
print("Running scenario file ({}/{}): {}".format(i + 1, total_scenario_files, scenario_file))
# Measure wall time and not cpu because it is the easiest.
wall_time_start = time.time()
# Use timout feature, check return value and capture stdout/stderr to a PIPE (use completed_process.stdout to get it).
completed_process = subprocess.run(args=["java", "-enableassertions", "-jar", vadere_console, scenario_file, output_dir],
timeout=scenario_timeout_in_sec,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
wall_time_end = time.time()
wall_time_delta = wall_time_end - wall_time_start
passed_scenarios = []
failed_scenarios_with_exception = []
print("Finished scenario file ({:.1f} s): {}".format(wall_time_delta, scenario_file))
for i, scenario_file in enumerate(scenario_files):
try:
print("Running scenario file ({}/{}): {}".format(i + 1, total_scenario_files, scenario_file))
# Measure wall time and not cpu because it is the easiest.
wall_time_start = time.time()
# Use timout feature, check return value and capture stdout/stderr to a PIPE (use completed_process.stdout to get it).
completed_process = subprocess.run(args=["java", "-enableassertions", "-jar", vadere_console, scenario_file, output_dir],
timeout=scenario_timeout_in_sec,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
wall_time_end = time.time()
wall_time_delta = wall_time_end - wall_time_start
print("Finished scenario file ({:.1f} s): {}".format(wall_time_delta, scenario_file))
passed_scenarios.append(scenario_file)
except subprocess.TimeoutExpired as exception:
print("Scenario file failed: {}".format(scenario_file))
print("-> Reason: timeout after {} s ({})".format(exception.timeout, exception.cmd))
failed_scenarios_with_exception.append((scenario_file, exception))
except subprocess.CalledProcessError as exception:
print("Scenario file failed: {}".format(scenario_file))
print("-> Reason: non-zero return value {} ({})".format(exception.returncode, exception.cmd))
failed_scenarios_with_exception.append((scenario_file, exception))
if os.path.exists(output_dir):
shutil.rmtree(output_dir)
return {"passed": passed_scenarios, "failed": failed_scenarios_with_exception}
if __name__ == "__main__":
scenario_files = find_scenario_files()
run_scenario_files_with_vadere_console(scenario_files)
passed_and_failed_scenarios = run_scenario_files_with_vadere_console(scenario_files)
if len(passed_and_failed_scenarios["failed"]) > 0:
exit(1)
else:
exit(0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment