Skip to content

Commit

Permalink
Testing: switch unit tests to BUILD_TESTING
Browse files Browse the repository at this point in the history
  • Loading branch information
MaEtUgR committed Apr 14, 2019
1 parent 3dd4488 commit ee9e99e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,6 @@ if (${PX4_PLATFORM} STREQUAL "posix")
if (NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install path prefix" FORCE)
endif()

# cmake testing only on posix
enable_testing()
include(CTest)
endif()

#=============================================================================
Expand Down Expand Up @@ -417,14 +413,18 @@ endif()
# Testing - Automatic unit and integration testing with CTest
#

option(unit_testing "Configure unit test targets" OFF)
# optionally enable cmake testing (supported only on posix)
option(testing "Configure unit test targets" OFF)
if(testing)
include(CTest)
endif()

list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/cmake/gtest/)
include(px4_add_gtest)

if(unit_testing)
include(gtest)
add_custom_target(unit_test COMMAND GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} -V -R UnitTest- USES_TERMINAL)
if(BUILD_TESTING)
include(gtest)
add_custom_target(unit_test COMMAND GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} -V -R UnitTest- USES_TERMINAL)
endif()

#=============================================================================
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,18 @@ format:

# Testing
# --------------------------------------------------------------------
.PHONY: tests tests_coverage tests_mission tests_mission_coverage tests_offboard tests_avoidance unit_test
.PHONY: test tests_coverage tests_mission tests_mission_coverage tests_offboard tests_avoidance unit_test
.PHONY: rostest python_coverage

unit_test:
$(eval CMAKE_ARGS += -Dunit_testing=ON)
test:
$(eval CMAKE_ARGS += -Dtesting=ON)
$(eval ARGS += unit_test)
$(call cmake-build,px4_sitl_default)

tests:
@$(MAKE) --no-print-directory px4_sitl_test test_results \
ASAN_OPTIONS="color=always:check_initialization_order=1:detect_stack_use_after_return=1" \
UBSAN_OPTIONS="color=always"
$(eval CMAKE_ARGS += -Dtesting=ON)
$(eval ARGS += test_results)
$(call cmake-build,px4_sitl_default)

tests_coverage:
@$(MAKE) clean
Expand Down
2 changes: 1 addition & 1 deletion cmake/gtest/px4_add_gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ include(px4_base)
#
function(px4_add_gtest)
# skip if unit testing is not configured
if(unit_testing)
if(BUILD_TESTING)
# parse source file and library dependencies from arguments
px4_parse_function_args(
NAME px4_add_gtest
Expand Down

0 comments on commit ee9e99e

Please sign in to comment.