Skip to content

Commit 40ecace

Browse files
committed
Fix #1115, Add absolute branch coverage check
Check for absolute number of missed branches in github workflow instead of checking a percentage. Ensure that the number of missed branches does not increase from the current 4 missed branches.
1 parent f11d049 commit 40ecace

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/local_unit_test.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,24 @@ 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+
missed_branches=4
46+
coverage_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[1-9]+[0-9]*")
47+
48+
diff=$(echo $coverage_nums | awk '{ print $4 - $3 }')
49+
if [ $(($diff > $missed_branches)) == 1 ]
50+
then
51+
grep -A 3 "Overall coverage rate" lcov_out.txt
52+
echo "More than $missed_branches branches missed"
53+
exit -1
54+
fi

0 commit comments

Comments
 (0)