Skip to content

Commit 9f7ebaa

Browse files
authored
Merge pull request #1117 from nmullane/fix1115-branch-coverage
Fix #1115, Add absolute branch coverage check
2 parents 7f4ba96 + dd1ebcc commit 9f7ebaa

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.github/workflows/local_unit_test.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,25 @@ jobs:
3131

3232
- name: Calculate coverage
3333
run: make lcov | tee lcov_out.txt
34-
34+
3535
- name: Confirm 100% line coverage
3636
run: |
3737
if [[ `grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines` != *"100.0%"* ]]; then
3838
grep -A 3 "Overall coverage rate" lcov_out.txt
3939
echo "Lacks 100.0% line unit test coverage"
4040
exit -1
4141
fi
42+
43+
- name: Confirm absolute line coverage
44+
run: |
45+
# Current best possible branch coverage is all but 4, with associated issues for each missing case
46+
missed_branches=4
47+
coverage_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[1-9]+[0-9]*")
48+
49+
diff=$(echo $coverage_nums | awk '{ print $4 - $3 }')
50+
if [ $(($diff > $missed_branches)) == 1 ]
51+
then
52+
grep -A 3 "Overall coverage rate" lcov_out.txt
53+
echo "More than $missed_branches branches missed"
54+
exit -1
55+
fi

0 commit comments

Comments
 (0)