70 lines
1.9 KiB
Python
70 lines
1.9 KiB
Python
#!/usr/bin/env python
|
|
import argparse
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add project root to path
|
|
sys.path.insert(0, str(Path(__file__).parents[2]))
|
|
|
|
from tests.unified.runner import UnifiedTestRunner
|
|
|
|
|
|
async def main():
|
|
parser = argparse.ArgumentParser(description="Run Unified Honcho Tests")
|
|
target_group = parser.add_mutually_exclusive_group()
|
|
target_group.add_argument(
|
|
"--test-dir",
|
|
type=str,
|
|
help="Directory containing JSON test files",
|
|
)
|
|
target_group.add_argument(
|
|
"--test-file",
|
|
type=str,
|
|
help="Path to a single JSON test file to run",
|
|
)
|
|
parser.add_argument(
|
|
"--port", type=int, default=9000, help="DB port for the harness"
|
|
)
|
|
parser.add_argument(
|
|
"--api-port", type=int, default=9001, help="API port for the harness"
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
if args.test_file is None and args.test_dir is None:
|
|
args.test_dir = "tests/unified/test_cases"
|
|
|
|
if args.test_file:
|
|
test_path = Path(args.test_file)
|
|
if not test_path.exists():
|
|
print(f"Error: Test file {test_path} does not exist.")
|
|
sys.exit(1)
|
|
if not test_path.is_file():
|
|
print(f"Error: {test_path} is not a file.")
|
|
sys.exit(1)
|
|
|
|
runner = UnifiedTestRunner(
|
|
test_file=test_path, honcho_port=args.port, api_port=args.api_port
|
|
)
|
|
else:
|
|
test_dir = Path(args.test_dir)
|
|
if not test_dir.exists():
|
|
print(f"Error: Directory {test_dir} does not exist.")
|
|
sys.exit(1)
|
|
|
|
runner = UnifiedTestRunner(
|
|
tests_dir=test_dir, honcho_port=args.port, api_port=args.api_port
|
|
)
|
|
|
|
# Non-zero on any failed or unrunnable test, so CI fails on results.
|
|
if await runner.run():
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
asyncio.run(main())
|
|
except KeyboardInterrupt:
|
|
print("\nInterrupted.")
|