Skip to content

Commit

Permalink
log errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Dec 3, 2023
1 parent 501fb3b commit 58c46e0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tools/ctest_exec_mp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import os
import sys
from pathlib import Path
Expand All @@ -18,12 +16,18 @@ def run_tests_log_to_file(data_dir, n_cores, tests):
""" ctest seems to merge stdout and stderr so we only need one output file """
import concurrent.futures

stdout_dir = data_dir/"stdout"
stdout_dir.mkdir(parents=True, exist_ok=True)
stderr_dir = data_dir/"stderr"
stderr_dir.mkdir(parents=True, exist_ok=True)

with concurrent.futures.ThreadPoolExecutor(max_workers=n_cores) as executor:
jobs = [
executor.submit(
run, cmake.test_cmd(test, verbose=True),
shell=True, capture_output=False, check=True,
stdout=open(os.path.join(str(data_dir), test), "w"))
shell=True, capture_output=False, check=False,
stdout=open(os.path.join(str(stdout_dir), test), "w"),
stderr=open(os.path.join(str(stderr_dir), test), "w"))
for i, test in enumerate(tests)
]
results = []
Expand All @@ -37,11 +41,13 @@ def run_tests_log_to_file(data_dir, n_cores, tests):
def main():
with pushd(os.path.join(str(root), "build")):
current_git_hash = git.hashes(1)[0]
data_dir = Path(os.path.join(str(root), "data_out", current_git_hash, "ctest_logs"))
os.makedirs(str(data_dir), exist_ok=True)
data_dir = Path(os.path.join(str(root), "data_out", current_git_hash))
N_CORES= int(os.environ["N_CORES"]) if "N_CORES" in os.environ else 1
print(f"Launching ctests with N_CORES {N_CORES}")
run_tests_log_to_file(data_dir, N_CORES, cmake.list_tests())
results = run_tests_log_to_file(data_dir, N_CORES, cmake.list_tests())
if any([result.returncode > 0 for result in results]):
sys.exit(1)


if __name__ == "__main__":
main()

0 comments on commit 58c46e0

Please sign in to comment.