Follow ctest and BUILD_TESTING best practices (#131)
This commit is contained in:
parent
c4864f1a5b
commit
acfa05a326
@ -54,5 +54,5 @@ install:
|
||||
|
||||
script:
|
||||
- mkdir -p build && cd build
|
||||
- cmake .. && make -j4
|
||||
- CTEST_OUTPUT_ON_FAILURE=1 make test
|
||||
- cmake .. -DBUILD_TESTING=ON && make -j4
|
||||
- CTEST_OUTPUT_ON_FAILURE=1 ctest -j4 -R uvw
|
||||
|
||||
@ -49,12 +49,6 @@ set(PROJECT_SRC_DIR ${uvw_SOURCE_DIR}/src)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
|
||||
|
||||
#
|
||||
# Enable test support using ctest-like interface
|
||||
#
|
||||
|
||||
option(BUILD_TESTING "Enable testing with ctest." ON)
|
||||
|
||||
#
|
||||
# Referenced packages
|
||||
#
|
||||
@ -81,9 +75,6 @@ if(BUILD_TESTING)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${PROJECT_DEPS_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${PROJECT_DEPS_DIR})
|
||||
|
||||
# Disable testing for dependencies
|
||||
set(BUILD_TESTING OFF)
|
||||
|
||||
# gtest, gtest_main, gmock and gmock_main targets are available from now on
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${GOOGLETEST_DEPS_DIR})
|
||||
@ -92,9 +83,6 @@ if(BUILD_TESTING)
|
||||
add_subdirectory(${LIBUV_DEPS_DIR})
|
||||
include_directories(${LIBUV_DEPS_DIR}/include)
|
||||
|
||||
# Enable testing for uvw
|
||||
set(BUILD_TESTING ON)
|
||||
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
|
||||
@ -147,9 +147,11 @@ To compile and run the tests, `uvw` requires *libuv* and *googletest*.<br/>
|
||||
To build the tests:
|
||||
|
||||
* `$ cd build`
|
||||
* `$ cmake ..`
|
||||
* `$ cmake .. -DBUILD_TESTING=ON`
|
||||
* `$ make`
|
||||
* `$ make test`
|
||||
* `$ ctest -j4 -R uvw`
|
||||
|
||||
Omit `-R uvw` if you also want to test `libuv` and other dependencies.
|
||||
|
||||
# Crash Course
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ macro(ADD_UVW_TEST TEST_NAME TEST_SOURCE)
|
||||
add_executable(${TEST_NAME} $<TARGET_OBJECTS:odr> ${TEST_SOURCE})
|
||||
target_include_directories(${TEST_NAME} PRIVATE ${UVW_SRC_DIR})
|
||||
target_link_libraries(${TEST_NAME} PRIVATE ${COMMON_LINK_LIBS})
|
||||
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
|
||||
add_test(NAME uvw_${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>)
|
||||
endmacro()
|
||||
|
||||
macro(ADD_UVW_DIR_TEST TEST_NAME TEST_SOURCE)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user