Skip to content

Commit

Permalink
add update regressions script
Browse files Browse the repository at this point in the history
  • Loading branch information
scottaiton committed May 28, 2024
1 parent de9c1bf commit 74cf43a
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions scripts/update_regressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /usr/bin/env python3

import os
import subprocess
import shutil
import time
import argparse

def run_ctest(build_dir, rerun_failed=False):
"""Run ctest in the specified build directory."""
if rerun_failed:
result = subprocess.run(['ctest', '--rerun-failed'], cwd=build_dir)
else:
result = subprocess.run(['ctest'], cwd=build_dir)
return result.returncode == 0

def handle_actual_files(src_dir):
"""Recursively rename .actual files by removing the .actual extension."""
actual_files_found = False
for root, _, files in os.walk(src_dir):
for file in files:
if file.endswith('.actual'):
actual_files_found = True
actual_file_path = os.path.join(root, file)
original_file_path = os.path.join(root, file[:-7]) # Remove the .actual extension
shutil.move(actual_file_path, original_file_path)
return actual_files_found

def main(build_dir, src_dir):
"""Run ctest repeatedly until no .actual files are produced."""
first_run = True
while True:
print("Running ctest...")
if run_ctest(build_dir, rerun_failed=not first_run):
print("All tests passed.")
break
print("Handling .actual files...")
if not handle_actual_files(src_dir):
print("No .actual files found.")
break
print(".actual files handled. Re-running failed tests...")
first_run = False
time.sleep(1) # Small delay to avoid rapid re-running

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run ctest and handle .actual files.')
parser.add_argument('--build', type=str, required=True, help='Path to the build directory')
parser.add_argument('--src', type=str, required=True, help='Path to the source directory')
args = parser.parse_args()

main(args.build, args.src)

0 comments on commit 74cf43a

Please sign in to comment.