Skip to content

Commit

Permalink
adding error output to script
Browse files Browse the repository at this point in the history
  • Loading branch information
landinjm committed Nov 19, 2024
1 parent 9fc31f5 commit 71de217
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions tests/automatic_tests/run_automatic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,48 @@ def compile_and_run_simulation(application_path):
os.remove(solution_file)

# Compile application
subprocess.call(
["cmake", "."], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
)
subprocess.call(["make"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
try:
subprocess.run(
["cmake", "."],
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
check=True,
)
subprocess.run(
["make"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True
)
print("Compiling complete.")
except subprocess.CalledProcessError as e:
# Print the error stream if there's a compilation error
print(
f"Compilation failed with error:\n{e.stderr.decode('utf-8')}",
file=sys.stderr,
)
sys.exit(1)

# Print successful compilation to screen
print(f"Compiling complete, running the regression test for {application_path}...")
print(f"Running the regression test for {application_path}...")
sys.stdout.flush()

# Run application with timer
start = time.time()
subprocess.call(
["mpirun", "-n", "1", "./main-release"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
try:
subprocess.run(
["mpirun", "-n", "1", "./main-release"],
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
check=True,
)
except subprocess.CalledProcessError as e:
# Print the error stream if the application fails
print(
f"Application execution failed with error:\n{e.stderr.decode('utf-8')}",
file=sys.stderr,
)
sys.exit(1)

end = time.time()
print(f"Application completed in {end - start:.2f} seconds.")

return end - start

Expand Down

0 comments on commit 71de217

Please sign in to comment.