-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathruntests.py
More file actions
executable file
·70 lines (64 loc) · 1.72 KB
/
runtests.py
File metadata and controls
executable file
·70 lines (64 loc) · 1.72 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
import os
import sys
import unittest
from time import time
ROOT_MODULE = "tests."
# Isolate tests to be run "suite[.Class.test_method]". Class and method are optional.
ISOLATE = os.getenv("VERMIN_TEST_ISOLATE")
if ISOLATE is not None:
ISOLATE = ROOT_MODULE + ISOLATE.strip()
SUITES = (
"general",
"config",
"arguments",
"lang",
"module",
"builtin_classes",
"class",
"exception",
"builtin_functions",
"builtin_constants",
"builtin_exceptions",
"function",
"constants",
"decorators",
"kwargs",
"strftime_directive",
"annotation",
"maybe_annotations",
"array_typecodes",
"codecs_error_handlers",
"codecs_encodings",
"exclusions",
"comment_exclusions",
"backports",
"bytes_directive",
"violations",
)
def runsuite(suite):
# skip suite if doesn't match isolation filter
suite = ROOT_MODULE + suite
if ISOLATE:
if ISOLATE != suite and not ISOLATE.startswith(suite + "."):
print("Skipping test suite: {}".format(suite))
return 0
print("Isolated test(s): {}".format(ISOLATE))
print("Running test suite: {}".format(suite))
# Buffer output such that only on test errors will stdout/stderr be shown.
if ISOLATE:
res = unittest.main(None, argv=[sys.argv[0], ISOLATE], exit=False, buffer=True).result
else:
res = unittest.main(suite, exit=False, buffer=True).result
if len(res.failures) > 0 or len(res.errors) > 0:
sys.exit(-1)
return res.testsRun
def execute():
total_tests = 0
for suite in SUITES:
total_tests += runsuite(suite)
return total_tests
if __name__ == '__main__':
start, total_tests = time(), execute()
secs = time() - start
print("Ran {} tests ({} suites) in {:.3f}s".format(total_tests, len(SUITES), secs))