-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcheck_coverage.py
More file actions
32 lines (27 loc) · 853 Bytes
/
check_coverage.py
File metadata and controls
32 lines (27 loc) · 853 Bytes
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
"""
Script to check if test coverage is above a predefined threshold.
Reads total coverage percentage from stdin (output of coverage report --format=total).
"""
import sys
THRESHOLD = 60 # Minimum required coverage percentage
if __name__ == "__main__":
try:
coverage = int(sys.stdin.read().strip())
except ValueError:
print("Error: could not parse coverage value from stdin.")
sys.exit(1)
print("Total coverage: {}%".format(coverage))
if coverage < THRESHOLD:
print(
"Coverage {}% is below the required threshold of {}%.".format(
coverage, THRESHOLD
)
)
sys.exit(1)
else:
print(
"Coverage {}% meets the required threshold of {}%.".format(
coverage, THRESHOLD
)
)
sys.exit(0)