Repository navigation
Expand file tree
/
Copy pathtesting.py
More file actions
74 lines (59 loc) · 1.75 KB
/
Copy pathtesting.py
File metadata and controls
74 lines (59 loc) · 1.75 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
71
72
73
74
from __future__ import print_function, division, absolute_import
import sys
import contextlib
import numba.unittest_support as unittest
from numba.tests import NumbaTestProgram
from numba.utils import StringIO
def discover_tests(startdir):
"""Discover test under a directory
"""
loader = unittest.TestLoader()
suite = loader.discover(startdir)
return suite
def run_tests(suite, xmloutput=None, verbosity=1):
"""
args
----
- suite [TestSuite]
A suite of all tests to run
- xmloutput [str or None]
Path of XML output directory (optional)
- verbosity [int]
Verbosity level of tests output
Returns the TestResult object after running the test *suite*.
"""
if xmloutput is not None:
import xmlrunner
runner = xmlrunner.XMLTestRunner(output=xmloutput)
else:
runner = None
prog = NumbaTestProgram(suite=suite, testRunner=runner, exit=False, verbosity=verbosity)
return prog.result
def test(**kwargs):
"""
Run all tests under ``numba.tests``.
kwargs
------
- descriptions
- verbosity
- buffer
- failfast
- xmloutput [str]
Path of XML output directory
"""
from numba import cuda
suite = discover_tests("numba.tests")
ok = run_tests(suite, **kwargs).wasSuccessful()
if ok:
if cuda.is_available():
gpus = cuda.list_devices()
if gpus and gpus[0].compute_capability >= (2, 0):
print("== Run CUDA tests ==")
ok = cuda.test()
else:
print("== Skipped CUDA tests because GPU CC < 2.0 ==")
else:
print("== Skipped CUDA tests ==")
return ok
if __name__ == "__main__":
sys.exit(0 if test() else 1)