2024-07-25 17:58:16 +02:00
|
|
|
import argparse
|
2024-07-31 10:11:54 +02:00
|
|
|
import json
|
2024-07-25 17:58:16 +02:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DIR_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
DIR_TESTS = os.path.join(DIR_ROOT, 'tests')
|
|
|
|
DIR_TEST_CASES = os.path.join(DIR_TESTS, 'test_cases')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def discover_and_run_tests(pattern='test*.py'):
|
|
|
|
suite = unittest.TestLoader().discover(start_dir=DIR_TEST_CASES, pattern=pattern)
|
|
|
|
return unittest.TextTestRunner().run(suite)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.path.insert(0, DIR_ROOT)
|
|
|
|
|
2024-07-31 10:11:54 +02:00
|
|
|
parser = argparse.ArgumentParser(description='Run regression tests.')
|
2024-07-25 17:58:16 +02:00
|
|
|
parser.add_argument('--pattern', default='test*.py', help='Pattern to select files in test/test_cases. Example: "test*.py" or "test_efficiency.py".')
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
from tests import HKTest
|
2024-07-31 10:11:54 +02:00
|
|
|
with open(os.path.join(DIR_TESTS, 'config.json')) as f:
|
|
|
|
HKTest.CONFIG = json.load(f)
|
2024-07-25 17:58:16 +02:00
|
|
|
|
|
|
|
result = discover_and_run_tests(pattern=args.pattern)
|
|
|
|
if result.wasSuccessful():
|
|
|
|
exit(0)
|
|
|
|
else:
|
|
|
|
exit(1)
|