From 4af55fe4919c3ca0353a7abad24e7450ea82f378 Mon Sep 17 00:00:00 2001 From: Tomas Baca Date: Fri, 9 Feb 2024 08:47:05 +0100 Subject: [PATCH] updated the test format --- CMakeLists.txt | 4 ++- test/all_tests.sh | 34 ------------------------ test/compile_tests.sh | 2 +- test/{coverage.sh => gather_coverage.sh} | 2 +- test/run_tests.sh | 8 ++++++ 5 files changed, 13 insertions(+), 37 deletions(-) delete mode 100755 test/all_tests.sh rename test/{coverage.sh => gather_coverage.sh} (80%) create mode 100755 test/run_tests.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c23d3e..0644970 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,9 @@ target_link_libraries(MrsUavAutostart_AutomaticStart ## | Testing | ## -------------------------------------------------------------- -if(CATKIN_ENABLE_TESTING) +if(CATKIN_ENABLE_TESTING AND MRS_ENABLE_TESTING) + + message(WARNING "Testing enabled.") add_subdirectory(test) diff --git a/test/all_tests.sh b/test/all_tests.sh deleted file mode 100755 index 6614ec3..0000000 --- a/test/all_tests.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/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 --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 diff --git a/test/compile_tests.sh b/test/compile_tests.sh index 999699e..efbc058 100755 --- a/test/compile_tests.sh +++ b/test/compile_tests.sh @@ -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 diff --git a/test/coverage.sh b/test/gather_coverage.sh similarity index 80% rename from test/coverage.sh rename to test/gather_coverage.sh index 9e75c23..27404da 100755 --- a/test/coverage.sh +++ b/test/gather_coverage.sh @@ -16,7 +16,7 @@ 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 -o coverage_html coverage.info.cleaned | tee /tmp/genhtml.log +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}'` diff --git a/test/run_tests.sh b/test/run_tests.sh new file mode 100755 index 0000000..6f0fb27 --- /dev/null +++ b/test/run_tests.sh @@ -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