Skip to content

Commit

Permalink
updated test format
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Feb 9, 2024
1 parent e09911c commit 6eaefc9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 37 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-Wall)
add_definitions(-Wextra)

if(NOT TESTING)
if(NOT MRS_ENABLE_TESTING)
message(WARNING "relwithdebinfo profile detected, building with -O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3")
endif()
Expand Down Expand Up @@ -451,7 +451,9 @@ target_link_libraries(uvdar_led_manager_node
## | Testing |
## --------------------------------------------------------------

if(CATKIN_ENABLE_TESTING)
if(CATKIN_ENABLE_TESTING AND MRS_ENABLE_TESTING)

message(WARNING "Testing enabled.")

add_subdirectory(test)

Expand Down
34 changes: 0 additions & 34 deletions test/all_tests.sh

This file was deleted.

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
8 changes: 8 additions & 0 deletions test/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/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

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

0 comments on commit 6eaefc9

Please sign in to comment.