forked from leo-editor/leo-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_travis_unit_tests.py
29 lines (29 loc) · 973 Bytes
/
run_travis_unit_tests.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
#@+leo-ver=5-thin
#@+node:ekr.20181009072707.1: * @file ../../run_travis_unit_tests.py
import os
import sys
import traceback
import unittest
tag = 'run_travis_unit_tests.py'
try:
base_dir = os.path.dirname(__file__)
unittests_dir = os.path.abspath(os.path.join(base_dir, 'leo', 'unittests'))
suite = unittest.TestLoader().discover(unittests_dir)
n = suite.countTestCases()
assert n > 10, n
runner = unittest.TextTestRunner(failfast=True, verbosity=1)
result = runner.run(suite)
if result.errors or result.failures:
errors, fails = len(result.errors), len(result.failures)
print(f"{tag}: {errors} errors, {fails} failures")
sys.exit(1)
print(f"{tag}: {n} unit tests passed.")
sys.exit(0)
except Exception:
typ, val, tb = sys.exc_info()
lines = traceback.format_exception(typ, val, tb)
print(f"{tag}: unexpected exception")
for line in lines:
print(line.rstrip())
sys.exit(1)
#@-leo