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 Aug 4, 2021
1 parent 1963483 commit dd1ebcc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .github/workflows/local_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,25 @@ 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: |
# Current best possible branch coverage is all but 4, with associated issues for each missing case
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 dd1ebcc

Please sign in to comment.