-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcoverage.py
55 lines (45 loc) · 2.01 KB
/
coverage.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 29 14:35:47 2021
@author: steven
"""
import json
MIN_FILE_COVERAGE = 58.4
MIN_PROJECT_COVERAGE = 60
untracked_modules = ['volmdlr/templates.py',
'volmdlr/code_aster.py',
'volmdlr/core_compiled.py',
'volmdlr/bspline_compiled.py',
"volmdlr/bspline_fitting.py",
"volmdlr/bspline_evaluators.py",
"volmdlr/discrete_representation_compiled.py",
"volmdlr/stl.py",
'nurbs/core.py',
'nurbs/helpers.py',
'nurbs/fitting.py',
'nurbs/operations.py',
'volmdlr/mesh.py',
'volmdlr/gmsh_vm.py',
'models/__init__.py',
'models/contours.py',
'models/bspline_curves.py',
]
print('untracked modules:', untracked_modules)
with open('coverage.json', 'r') as file:
d = json.load(file)
project_coverage = d['totals']['percent_covered']
print(f'total covered: {project_coverage} %')
assert project_coverage > MIN_PROJECT_COVERAGE
print(f'[Coverage] You can increase MIN_PROJECT_COVERAGE to maximum {project_coverage}% (actual {MIN_PROJECT_COVERAGE}%)')
min_actual_coverage = 100
for file_name, data in d['files'].items():
print(file_name, data['summary']['percent_covered'], '%')
if '/'.join(file_name.split('/')[-2:]) in untracked_modules:
print(file_name, '-> in untrack list')
else:
file_coverage = data['summary']['percent_covered']
if file_coverage < MIN_FILE_COVERAGE:
raise RuntimeError(f'File {file_name} is not covered enough: {file_coverage} % / {MIN_FILE_COVERAGE} %')
min_actual_coverage = min(min_actual_coverage, data['summary']['percent_covered'])
print('[Coverage] You can increase MIN_FILE_COVERAGE to maximum {}% (actual:{})%'.format(min_actual_coverage, MIN_FILE_COVERAGE))