forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunUnittests.py
executable file
·34 lines (25 loc) · 1.07 KB
/
runUnittests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python3
import os
import sys
import unittest
"""
This is the equivalent of running:
python -m unittest discover --start-directory {test_discovery_path} --pattern {UNIT_TEST_PATTERN}
"""
# This is work-around for https://bugs.webkit.org/show_bug.cgi?id=222361
from buildbot.process.buildstep import BuildStep
BuildStep.warn_deprecated_if_oldstyle_subclass = lambda self, name: None
UNIT_TEST_PATTERN = '*_unittest.py'
def run_unittests(test_discovery_path):
test_suite = unittest.defaultTestLoader.discover(test_discovery_path, pattern=UNIT_TEST_PATTERN)
results = unittest.TextTestRunner(buffer=True).run(test_suite)
if results.failures or results.errors:
raise RuntimeError('Test failures or errors were generated during this test run.')
if __name__ == '__main__':
try:
relative_path = sys.argv[1]
except IndexError:
relative_path = os.path.dirname(__file__)
path = os.path.abspath(relative_path)
assert os.path.isdir(path), '{} is not a directory. Please specify a valid directory'.format(path)
run_unittests(path)