Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
numba
GitHub Repository: numba/llvmlite
Path: blob/main/run_coverage.py
1154 views
1
#!/usr/bin/env python
2
"""
3
Run code coverage sampling over the test suite, and produce
4
an HTML report in "htmlcov".
5
"""
6
7
import os
8
import shutil
9
10
try:
11
import coverage
12
except ImportError:
13
raise ImportError("Please install the coverage module "
14
"(https://pypi.python.org/pypi/coverage/)")
15
16
17
if __name__ == "__main__":
18
# We must start coverage before importing the package under test,
19
# otherwise some lines will be missed.
20
config_file = os.path.join(
21
os.path.dirname(os.path.dirname(__file__)),
22
'.coveragerc')
23
os.environ['COVERAGE_PROCESS_START'] = config_file
24
cov = coverage.coverage(config_file=config_file)
25
cov.start()
26
27
from llvmlite.tests import run_tests
28
29
html_dir = 'htmlcov'
30
try:
31
run_tests()
32
finally:
33
cov.stop()
34
cov.save()
35
cov.combine()
36
if os.path.exists(html_dir):
37
shutil.rmtree(html_dir)
38
cov.html_report(directory=html_dir)
39
40