Skip to content

Commit acfa05a

Browse files
Qix-skypjack
authored andcommitted
Follow ctest and BUILD_TESTING best practices (skypjack#131)
1 parent c4864f1 commit acfa05a

File tree

4 files changed

+7
-17
lines changed

4 files changed

+7
-17
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ install:
5454

5555
script:
5656
- mkdir -p build && cd build
57-
- cmake .. && make -j4
58-
- CTEST_OUTPUT_ON_FAILURE=1 make test
57+
- cmake .. -DBUILD_TESTING=ON && make -j4
58+
- CTEST_OUTPUT_ON_FAILURE=1 ctest -j4 -R uvw

CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ set(PROJECT_SRC_DIR ${uvw_SOURCE_DIR}/src)
4949

5050
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
5151

52-
#
53-
# Enable test support using ctest-like interface
54-
#
55-
56-
option(BUILD_TESTING "Enable testing with ctest." ON)
57-
5852
#
5953
# Referenced packages
6054
#
@@ -81,9 +75,6 @@ if(BUILD_TESTING)
8175
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${PROJECT_DEPS_DIR})
8276
execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${PROJECT_DEPS_DIR})
8377

84-
# Disable testing for dependencies
85-
set(BUILD_TESTING OFF)
86-
8778
# gtest, gtest_main, gmock and gmock_main targets are available from now on
8879
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
8980
add_subdirectory(${GOOGLETEST_DEPS_DIR})
@@ -92,9 +83,6 @@ if(BUILD_TESTING)
9283
add_subdirectory(${LIBUV_DEPS_DIR})
9384
include_directories(${LIBUV_DEPS_DIR}/include)
9485

95-
# Enable testing for uvw
96-
set(BUILD_TESTING ON)
97-
9886
add_subdirectory(test)
9987
endif()
10088

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ To compile and run the tests, `uvw` requires *libuv* and *googletest*.<br/>
147147
To build the tests:
148148

149149
* `$ cd build`
150-
* `$ cmake ..`
150+
* `$ cmake .. -DBUILD_TESTING=ON`
151151
* `$ make`
152-
* `$ make test`
152+
* `$ ctest -j4 -R uvw`
153+
154+
Omit `-R uvw` if you also want to test `libuv` and other dependencies.
153155

154156
# Crash Course
155157

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ macro(ADD_UVW_TEST TEST_NAME TEST_SOURCE)
2626
add_executable(${TEST_NAME} $<TARGET_OBJECTS:odr> ${TEST_SOURCE})
2727
target_include_directories(${TEST_NAME} PRIVATE ${UVW_SRC_DIR})
2828
target_link_libraries(${TEST_NAME} PRIVATE ${COMMON_LINK_LIBS})
29-
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
29+
add_test(NAME uvw_${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>)
3030
endmacro()
3131

3232
macro(ADD_UVW_DIR_TEST TEST_NAME TEST_SOURCE)

0 commit comments

Comments
 (0)