Skip to content

Commit 63f81e4

Browse files
committed
Problem: code coverage not working
Solution: build tests within cppzmq build, and add separate demo
1 parent b737b9f commit 63f81e4

File tree

6 files changed

+45
-12
lines changed

6 files changed

+45
-12
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ script:
4141
- ./ci_build.sh
4242

4343
after_success:
44-
- coveralls --root . -E ".*external.*" -E ".*CMakeFiles.*" -E ".*tests/" -E ".*libzmq/"
44+
- coveralls --root . -E ".*external.*" -E ".*CMakeFiles.*" -E ".*tests/" -E ".*demo/" -E ".*libzmq/"

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
6363
DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
6464
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/libzmq-pkg-config/FindZeroMQ.cmake
6565
DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR}/libzmq-pkg-config)
66+
67+
enable_testing()
68+
add_subdirectory(tests)

ci_build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ pushd .
2929
mkdir build
3030
cd build
3131
cmake ..
32+
cmake --build .
3233
sudo make -j4 install
34+
make test ARGS="-V"
3335
popd
3436

35-
# build cppzmq tests
36-
cd tests
37+
# build cppzmq demo
38+
cd demo
3739
mkdir build
3840
cd build
3941
cmake ..

demo/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
2+
3+
project(cppzmq-demo CXX)
4+
5+
find_package(cppzmq)
6+
7+
enable_testing()
8+
add_executable(
9+
demo
10+
main.cpp
11+
)
12+
13+
target_link_libraries(
14+
demo
15+
libzmq
16+
)
17+
18+
add_test(
19+
NAME
20+
demo
21+
COMMAND
22+
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/demo
23+
)

demo/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <zmq.hpp>
2+
3+
int main(int argc, char** argv)
4+
{
5+
zmq::context_t context;
6+
7+
return 0;
8+
}

tests/CMakeLists.txt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
33
project(cppzmq-test CXX)
44

55
# place binaries and libraries according to GNU standards
6-
# TODO check if we should do this
76

8-
# include(GNUInstallDirs)
9-
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
10-
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
11-
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
7+
include(GNUInstallDirs)
8+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
9+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
10+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
1211

1312
# we use this to get code coverage
1413
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
@@ -20,10 +19,6 @@ fetch_googletest(
2019
${PROJECT_SOURCE_DIR}/cmake
2120
${PROJECT_BINARY_DIR}/googletest
2221
)
23-
24-
find_package(cppzmq)
25-
26-
enable_testing()
2722

2823
add_executable(
2924
unit_tests
@@ -36,6 +31,8 @@ target_link_libraries(
3631
libzmq
3732
)
3833

34+
target_include_directories(unit_tests PRIVATE ..)
35+
3936
add_test(
4037
NAME
4138
unit

0 commit comments

Comments
 (0)