Simam3D-GPU / run_regression_tests.py
junaid-simamdigital's picture
test: discover regression suite dynamically
d816dac verified
Raw History Blame Contribute Delete
970 Bytes
"""Run every repository regression function and report an exact count."""
from __future__ import annotations
import inspect
import pathlib
import runpy
def run(root: pathlib.Path | None = None) -> int:
root = root or pathlib.Path(".")
count = 0
for test_path in sorted((root / "tests").glob("test_*.py")):
namespace = runpy.run_path(str(test_path))
for name, function in sorted(namespace.items()):
if not name.startswith("test_") or not callable(function):
continue
parameters = list(inspect.signature(function).parameters)
if parameters:
if parameters != ["tmp_path"]:
raise TypeError(f"unsupported test parameters in {test_path.name}:{name}: {parameters}")
function(root)
else:
function()
count += 1
print(f"tests passed: {count}")
return count
if __name__ == "__main__":
run()