Skip to content

Commit

Permalink
Problem: no build/tests with DRAFT
Browse files Browse the repository at this point in the history
Solution: added initial test case
  • Loading branch information
sigiesec committed Apr 3, 2018
1 parent 68cbb9e commit cc5f405
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ matrix:
packages:
- g++-7
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" BUILD_TYPE=cmake ZMQ_VERSION=4.2.5
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" BUILD_TYPE=cmake ZMQ_VERSION=4.2.5 DRAFT=1

sudo: required

Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ if (ZeroMQ_FOUND AND (NOT TARGET libzmq OR NOT TARGET libzmq-static))
message(FATAL_ERROR "ZeroMQ version not supported!")
endif()

if (EXISTS "${SOURCE_DIR}/.git")
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON)
else ()
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF)
endif ()
IF (ENABLE_DRAFTS)
ADD_DEFINITIONS (-DZMQ_BUILD_DRAFT_API)
set (pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1")
ELSE (ENABLE_DRAFTS)
set (pkg_config_defines "")
ENDIF (ENABLE_DRAFTS)

message(STATUS "cppzmq v${CPPZMQ_VERSION}")

set(CPPZMQ_HEADERS
Expand Down
11 changes: 9 additions & 2 deletions ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
set -x
set -e

if [ "$DRAFT" = "1" ] ; then
# if we enable drafts during the libzmq cmake build, the pkgconfig
# data should set ZMQ_BUILD_DRAFT_API in dependent builds, but this
# does not appear to work (TODO)
export ZEROMQ_CMAKE_FLAGS="-DENABLE_DRAFTS=ON"
fi

install_zeromq() {
pushd .

Expand All @@ -14,7 +21,7 @@ install_zeromq() {

mkdir build
cd build
cmake ..
cmake .. ${ZEROMQ_CMAKE_FLAGS}
sudo make -j4 install

popd
Expand All @@ -29,7 +36,7 @@ if [ "${ZMQ_VERSION}" != "" ] ; then install_zeromq ; fi
pushd .
mkdir build
cd build
cmake ..
cmake .. ${ZEROMQ_CMAKE_FLAGS}
cmake --build .
sudo make -j4 install
make test ARGS="-V"
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ add_executable(
unit_tests
context.cpp
socket.cpp
poller.cpp
)

target_link_libraries(
Expand Down
9 changes: 9 additions & 0 deletions tests/poller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <gtest/gtest.h>
#include <zmq.hpp>

#if defined(ZMQ_CPP11) && defined(ZMQ_BUILD_DRAFT_API)
TEST(poller, create_destroy)
{
zmq::poller_t context;
}
#endif

0 comments on commit cc5f405

Please sign in to comment.