Skip to content

Commit

Permalink
Fix nasa#1115, Add absolute branch coverage check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nmullane committed Jul 29, 2021
1 parent f11d049 commit 40ecace
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/local_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,24 @@ jobs:

- name: Calculate coverage
run: make lcov | tee lcov_out.txt

- name: Confirm 100% line coverage
run: |
if [[ `grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines` != *"100.0%"* ]]; then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "Lacks 100.0% line unit test coverage"
exit -1
fi
- name: Confirm absolute line coverage
run: |
missed_branches=4
coverage_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[1-9]+[0-9]*")
diff=$(echo $coverage_nums | awk '{ print $4 - $3 }')
if [ $(($diff > $missed_branches)) == 1 ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "More than $missed_branches branches missed"
exit -1
fi

0 comments on commit 40ecace

Please sign in to comment.