mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
Testing: Clean up unit_test target because test_results does all tests now
This commit is contained in:
@@ -416,18 +416,30 @@ endif()
|
|||||||
# optionally enable cmake testing (supported only on posix)
|
# optionally enable cmake testing (supported only on posix)
|
||||||
option(CMAKE_TESTING "Configure test targets" OFF)
|
option(CMAKE_TESTING "Configure test targets" OFF)
|
||||||
if(CMAKE_TESTING)
|
if(CMAKE_TESTING)
|
||||||
include(CTest)
|
include(CTest) # sets BUILD_TESTING variable
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# enable test filtering to run only specific tests with the ctest -R regex functionality
|
||||||
set(TESTFILTER "" CACHE STRING "Filter string for ctest to selectively only run specific tests (ctest -R)")
|
set(TESTFILTER "" CACHE STRING "Filter string for ctest to selectively only run specific tests (ctest -R)")
|
||||||
|
|
||||||
|
# if testing is enabled download and configure gtest
|
||||||
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake/gtest/)
|
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake/gtest/)
|
||||||
include(px4_add_gtest)
|
include(px4_add_gtest)
|
||||||
|
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
include(gtest)
|
include(gtest)
|
||||||
add_custom_target(unit_test COMMAND GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} -V -R ${TESTFILTER} USES_TERMINAL)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(test_results
|
||||||
|
COMMAND GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} --output-on-failure -T Test -R ${TESTFILTER} USES_TERMINAL
|
||||||
|
DEPENDS
|
||||||
|
px4
|
||||||
|
examples__dyn_hello
|
||||||
|
test_mixer_multirotor
|
||||||
|
USES_TERMINAL
|
||||||
|
COMMENT "Running tests"
|
||||||
|
WORKING_DIRECTORY ${PX4_BINARY_DIR})
|
||||||
|
set_target_properties(test_results PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# subdirectories
|
# subdirectories
|
||||||
#
|
#
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -340,15 +340,9 @@ format:
|
|||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
.PHONY: tests tests_coverage tests_mission tests_mission_coverage tests_offboard tests_avoidance unit_test
|
.PHONY: tests tests_coverage tests_mission tests_mission_coverage tests_offboard tests_avoidance
|
||||||
.PHONY: rostest python_coverage
|
.PHONY: rostest python_coverage
|
||||||
|
|
||||||
unit_test:
|
|
||||||
$(eval CMAKE_ARGS += -DCMAKE_TESTING=ON)
|
|
||||||
$(eval CMAKE_ARGS += -DCONFIG=px4_sitl_test)
|
|
||||||
$(eval ARGS += unit_test)
|
|
||||||
$(call cmake-build,px4_sitl_test)
|
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
$(eval CMAKE_ARGS += -DCMAKE_TESTING=ON)
|
$(eval CMAKE_ARGS += -DCMAKE_TESTING=ON)
|
||||||
$(eval CMAKE_ARGS += -DCONFIG=px4_sitl_test)
|
$(eval CMAKE_ARGS += -DCONFIG=px4_sitl_test)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ include(px4_base)
|
|||||||
#
|
#
|
||||||
# px4_add_gtest
|
# px4_add_gtest
|
||||||
#
|
#
|
||||||
# Adds a googletest unit test to the unit_test target.
|
# Adds a googletest unit test to the test_results target.
|
||||||
#
|
#
|
||||||
function(px4_add_gtest)
|
function(px4_add_gtest)
|
||||||
# skip if unit testing is not configured
|
# skip if unit testing is not configured
|
||||||
@@ -65,6 +65,6 @@ function(px4_add_gtest)
|
|||||||
add_test(NAME ${TESTNAME} COMMAND ${TESTNAME})
|
add_test(NAME ${TESTNAME} COMMAND ${TESTNAME})
|
||||||
|
|
||||||
# attach it to the unit test target
|
# attach it to the unit test target
|
||||||
add_dependencies(unit_test ${TESTNAME})
|
add_dependencies(test_results ${TESTNAME})
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -145,19 +145,6 @@ foreach(cmd_name ${test_cmds})
|
|||||||
set_tests_properties(posix_${cmd_name} PROPERTIES PASS_REGULAR_EXPRESSION "Shutting down")
|
set_tests_properties(posix_${cmd_name} PROPERTIES PASS_REGULAR_EXPRESSION "Shutting down")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
add_custom_target(test_results
|
|
||||||
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -T Test -R ${TESTFILTER}
|
|
||||||
DEPENDS
|
|
||||||
px4
|
|
||||||
examples__dyn_hello
|
|
||||||
test_mixer_multirotor
|
|
||||||
unit_test
|
|
||||||
USES_TERMINAL
|
|
||||||
COMMENT "Running tests in sitl"
|
|
||||||
WORKING_DIRECTORY ${PX4_BINARY_DIR})
|
|
||||||
set_target_properties(test_results PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL Coverage)
|
if (CMAKE_BUILD_TYPE STREQUAL Coverage)
|
||||||
setup_target_for_coverage(test_coverage "${CMAKE_CTEST_COMMAND} --output-on-failure -T Test" tests)
|
setup_target_for_coverage(test_coverage "${CMAKE_CTEST_COMMAND} --output-on-failure -T Test" tests)
|
||||||
setup_target_for_coverage(generate_coverage "${CMAKE_COMMAND} -E echo" generic)
|
setup_target_for_coverage(generate_coverage "${CMAKE_COMMAND} -E echo" generic)
|
||||||
|
|||||||
Reference in New Issue
Block a user