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 26, 2021
1 parent a3b7012 commit 3d8fd31
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/local_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ jobs:
- name: Calculate coverage
run: make lcov | tee lcov_out.txt

- name: Confirm 100% line coverage
- name: Confirm absolute line coverage
run: |
if [[ `grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines` != *"100.0%"* ]]; then
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 "Lacks 100.0% line unit test coverage"
echo "More than $missed_branches branches missed"
exit -1
fi

0 comments on commit 3d8fd31

Please sign in to comment.