@@ -40,20 +40,87 @@ python3 "$SCRIPT_DIR/dependency-parser/main.py" select "$JSON_FILE" origin/devel
4040# Path to tests_to_run.json in the same directory
4141TEST_FILE=" tests_to_run.json"
4242
43- command=$( python3 -c "
43+ # Configuration: Adjust these defaults as needed
44+ # Number of tests per ctest command (can be overridden with CTEST_CHUNK_SIZE env var)
45+ DEFAULT_CHUNK_SIZE=10
46+ # Whether to stop on first failure (can be overridden with CTEST_FAIL_FAST env var)
47+ DEFAULT_FAIL_FAST=false
48+
49+ # Split tests into chunks and run multiple ctest commands
50+ CHUNK_SIZE=${CTEST_CHUNK_SIZE:- $DEFAULT_CHUNK_SIZE }
51+ FAIL_FAST=${CTEST_FAIL_FAST:- $DEFAULT_FAIL_FAST }
52+
53+ python3 -c "
4454import json
4555import os
56+ import sys
57+ import subprocess
58+
59+ CHUNK_SIZE = int(os.environ.get('CHUNK_SIZE', '10'))
60+ FAIL_FAST = os.environ.get('FAIL_FAST', 'false').lower() == 'true'
61+
4662with open('$TEST_FILE ', 'r') as f:
4763 data = json.load(f)
4864 tests = data.get('tests_to_run', [])
49- if tests:
50- # Extract just the filename after the last '/'
51- clean_tests = [os.path.basename(test) for test in tests]
52- print('ctest --output-on-failure -R \" ' + '|'.join(clean_tests) + '\" ')
53- else:
65+
66+ if not tests:
5467 print('# No tests to run')
55- " )
56-
57- echo " $command "
68+ sys.exit(0)
69+
70+ # Extract just the filename after the last '/'
71+ clean_tests = [os.path.basename(test) for test in tests]
72+
73+ total_tests = len(clean_tests)
74+ total_chunks = (total_tests + CHUNK_SIZE - 1) // CHUNK_SIZE
75+
76+ print(f'# Total tests to run: {total_tests}')
77+ print(f'# Running in {total_chunks} chunk(s) of up to {CHUNK_SIZE} tests each')
78+ print(f'# Fail-fast mode: {FAIL_FAST}')
79+ print()
80+
81+ failed_chunks = []
82+
83+ # Split into chunks
84+ for i in range(0, total_tests, CHUNK_SIZE):
85+ chunk = clean_tests[i:i+CHUNK_SIZE]
86+ chunk_num = (i // CHUNK_SIZE) + 1
87+
88+ print(f'Running test chunk {chunk_num}/{total_chunks} ({len(chunk)} tests)...')
89+ sys.stdout.flush()
90+
91+ # Run ctest command, don't raise exception on failure
92+ cmd = ['ctest', '--output-on-failure', '-R', '|'.join(chunk)]
93+ try:
94+ result = subprocess.run(cmd, cwd='$BUILD_DIR ', check=False)
95+
96+ if result.returncode != 0:
97+ failed_chunks.append(chunk_num)
98+ print(f'WARNING: Chunk {chunk_num} had test failures (exit code: {result.returncode})')
99+
100+ # If fail-fast is enabled, exit immediately
101+ if FAIL_FAST:
102+ print(f'FAIL-FAST: Stopping at chunk {chunk_num} due to failures')
103+ sys.exit(1)
104+ except Exception as e:
105+ print(f'ERROR: Failed to run chunk {chunk_num}: {e}')
106+ failed_chunks.append(chunk_num)
107+ if FAIL_FAST:
108+ sys.exit(1)
109+
110+ print()
111+ sys.stdout.flush()
112+
113+ # Print summary
114+ print('=' * 60)
115+ if failed_chunks:
116+ print(f'SUMMARY: {len(failed_chunks)} of {total_chunks} chunk(s) had failures: {failed_chunks}')
117+ print('=' * 60)
118+ sys.exit(1)
119+ else:
120+ print(f'SUMMARY: All {total_chunks} chunk(s) passed successfully!')
121+ print('=' * 60)
122+ sys.exit(0)
123+ "
124+ PYTHON_EXIT=$?
58125
59- eval " $command "
126+ exit $PYTHON_EXIT
0 commit comments