run tests batched script
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def run_tests():
|
||||
test_dir = "tests"
|
||||
test_files = [f for f in os.listdir(test_dir) if f.startswith("test_") and f.endswith(".py")]
|
||||
test_files.sort()
|
||||
|
||||
batch_size = 4
|
||||
all_failed = []
|
||||
|
||||
print(f"Starting test execution of {len(test_files)} files in batches of {batch_size}...")
|
||||
|
||||
for i in range(0, len(test_files), batch_size):
|
||||
batch = test_files[i:i + batch_size]
|
||||
cmd = ["uv", "run", "pytest", "--maxfail=10"] + [os.path.join(test_dir, f) for f in batch]
|
||||
print(f"\nBatch {i//batch_size + 1}: {' '.join(batch)}")
|
||||
try:
|
||||
subprocess.run(cmd, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
print(f"Batch {i//batch_size + 1} failed.")
|
||||
all_failed.extend(batch)
|
||||
|
||||
if all_failed:
|
||||
print("\n" + "="*30)
|
||||
print(f"Total batches with failures: {len(all_failed)//batch_size + 1 if len(all_failed)%batch_size else len(all_failed)//batch_size}")
|
||||
print("Files in failed batches:")
|
||||
for f in all_failed:
|
||||
print(f" - {f}")
|
||||
print("="*30)
|
||||
else:
|
||||
print("\nAll batches passed successfully!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_tests()
|
||||
Reference in New Issue
Block a user