testr/testr.py

35 lines
987 B
Python
Raw Normal View History

2023-11-02 15:06:32 -04:00
import asyncio
from pathlib import Path
from testr.file_data import DirectorySuite, ExecutableRunner
2023-11-02 15:23:09 -04:00
from testr.runner import TestOptions
2023-10-14 21:13:37 -04:00
import argparse
parser = argparse.ArgumentParser()
2023-11-02 15:06:32 -04:00
test_runner_group = parser.add_mutually_exclusive_group(required=True)
test_data_group = parser.add_mutually_exclusive_group(required=True)
test_data_group.add_argument("--testdir", help="Directory for test cases")
test_runner_group.add_argument("--exec", help="Executable to run test cases against")
2023-11-02 15:23:09 -04:00
parser.add_argument("--timelim", help="Time limit in seconds", type=float, default=5.0)
2023-11-02 15:06:32 -04:00
args = parser.parse_args()
2023-11-02 15:23:09 -04:00
2023-11-02 15:06:32 -04:00
async def main():
test_suite = DirectorySuite(Path(args.testdir))
test_runner = ExecutableRunner(Path(args.exec))
2023-11-02 15:23:09 -04:00
async for test_case in test_runner.run_test_suite(
test_suite,
TestOptions(
time_limit=args.timelim
)
):
2023-11-02 15:06:32 -04:00
print(test_case.code)
2023-11-02 15:23:09 -04:00
2023-11-02 15:06:32 -04:00
if __name__ == "__main__":
asyncio.run(main())