Skip to content

Commit

Permalink
updated the test format
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Feb 9, 2024
1 parent 09606af commit b67a436
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ add_dependencies(MrsUavStateEstimators_GarminAgl
## | Testing |
## --------------------------------------------------------------

if(CATKIN_ENABLE_TESTING)
if(CATKIN_ENABLE_TESTING AND MRS_ENABLE_TESTING)

message(WARNING "Testing enabled.")

add_subdirectory(test)

Expand Down
2 changes: 1 addition & 1 deletion test/compile_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR

# build the package
catkin build --this # it has to be fully built normally before building with --catkin-make-args tests
catkin build --this --no-deps --catkin-make-args tests
catkin build --this -DMRS_ENABLE_TESTING=1 --no-deps --catkin-make-args tests
25 changes: 25 additions & 0 deletions test/gather_coverage.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions test/all_tests.sh → test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ set -e
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR

# build the package
catkin build --this # it has to be fully built normally before building with --catkin-make-args tests
catkin build --this --no-deps --catkin-make-args tests

catkin test --this -i -p 1 -s

0 comments on commit b67a436

Please sign in to comment.