diff --git a/test/all_tests.sh b/test/all_tests.sh new file mode 100755 index 0000000..1c1168e --- /dev/null +++ b/test/all_tests.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR + +ORIGINAL_PATH=`pwd` + +while [ ! -e ".catkin_tools" ]; do + cd .. + if [[ `pwd` == "/" ]]; then + # we reached the root and didn't find the build/COLCON_IGNORE file - that's a fail! + echo "$0: could not find the root of the current workspace". + return 1 + fi +done + +cd build + +OLD_FILES=$(find . -name "*.gcda") + +for FILE in $OLD_FILES; do + echo "$0: removing old coverage file '$FILE'" + rm $FILE +done + +cd $ORIGINAL_PATH + +# build the package +catkin build # it has to be fully built normally before building with --catkin-make-args tests +catkin build --catkin-make-args tests + +catkin test -i -p 1 -s diff --git a/test/coverage.sh b/test/coverage.sh new file mode 100755 index 0000000..27404da --- /dev/null +++ b/test/coverage.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +while [ ! -e ".catkin_tools" ]; do + cd .. + if [[ `pwd` == "/" ]]; then + # we reached the root and didn't find the build/COLCON_IGNORE file - that's a fail! + echo "$0: could not find the root of the current workspace". + return 1 + fi +done + +WORKSPACE_NAME=${PWD##*/} + +cd build + +lcov --capture --directory . --output-file coverage.info +lcov --remove coverage.info "*/test/*" --output-file coverage.info.removed +lcov --extract coverage.info.removed "*/${WORKSPACE_NAME}/src/*" --output-file coverage.info.cleaned +genhtml --title "MRS UAV System - Test coverage report" --demangle-cpp --legend --frames --show-details -o coverage_html coverage.info.cleaned | tee /tmp/genhtml.log + +COVERAGE_PCT=`cat /tmp/genhtml.log | tail -n 1 | awk '{print $2}'` + +echo "Coverage: $COVERAGE_PCT" + +xdg-open coverage_html/index.html