-
Notifications
You must be signed in to change notification settings - Fork 21
/
cover.py
executable file
·82 lines (47 loc) · 1.63 KB
/
cover.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
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
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
#
# cover.py
# Copyright (c) 2020 Raphael DINGE
#
#Tab=3########################################################################
##### IMPORT #################################################################
from __future__ import print_function
import os
import subprocess
import sys
##############################################################################
if sys.version_info < (3, 7):
print ('This script requires python 3.7 or greater.', file=sys.stderr)
sys.exit (1)
PATH_THIS = os.path.abspath (os.path.dirname (__file__))
COVERAGE = 'coverage3'
#-- erase_coverage_data ---------------------------------------------------
def erase_coverage_data ():
subprocess.check_call (
[COVERAGE, 'erase']
)
#-- collect ---------------------------------------------------------------
def collect (module_name):
subprocess.check_call (
[COVERAGE, 'run', '-a', '-m', module_name],
stdout = subprocess.DEVNULL,
stderr = subprocess.STDOUT
)
#-- report ----------------------------------------------------------------
def report ():
EXCLUDED_PATHS = '*/gyp/*,*/arpeggio/*'
subprocess.check_call (
[COVERAGE, 'report', '--omit', EXCLUDED_PATHS]
)
subprocess.check_call (
[COVERAGE, 'html', '--omit', EXCLUDED_PATHS]
)
#-- main ------------------------------------------------------------------
def main ():
os.chdir (PATH_THIS)
erase_coverage_data ()
collect ('erbui.tests.test_parser')
report ()
##############################################################################
if __name__ == '__main__':
sys.exit (main ())