mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-04-01 09:24:53 +02:00
Merge pull request #192 from sigiesec/add-travis-ci
Add basic test infrastructure
This commit is contained in:
commit
7db13d356a
15
.travis.yml
15
.travis.yml
@ -1,6 +1,6 @@
|
||||
# Travis CI script
|
||||
|
||||
language: c
|
||||
language: cpp
|
||||
|
||||
os:
|
||||
- linux
|
||||
@ -10,10 +10,15 @@ dist: trusty
|
||||
|
||||
cache: ccache
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
env:
|
||||
matrix:
|
||||
# - BUILD_TYPE=cmake DRAFT=enabled
|
||||
- BUILD_TYPE=cmake
|
||||
- BUILD_TYPE=cmake ZMQ_VERSION=4.2.5
|
||||
|
||||
matrix:
|
||||
include:
|
||||
@ -28,6 +33,12 @@ matrix:
|
||||
|
||||
sudo: required
|
||||
|
||||
before_install:
|
||||
- pip install --user cpp-coveralls
|
||||
|
||||
# Build and check this project according to the BUILD_TYPE
|
||||
script:
|
||||
- ./ci_build.sh
|
||||
|
||||
after_success:
|
||||
- coveralls --root . -E ".*external.*" -E ".*CMakeFiles.*" -E ".*tests/" -E ".*libzmq/"
|
||||
|
17
ci_build.sh
17
ci_build.sh
@ -7,9 +7,9 @@ install_zeromq() {
|
||||
|
||||
mkdir libzmq
|
||||
cd libzmq
|
||||
curl -L https://github.com/zeromq/libzmq/releases/download/v${ZMQ_VERSION}/zeromq-${ZMQ_VERSION}.tar.gz >zeromq.tar.gz
|
||||
curl -L https://github.com/zeromq/libzmq/archive/v${ZMQ_VERSION}.tar.gz >zeromq.tar.gz
|
||||
tar -xvzf zeromq.tar.gz
|
||||
cd zeromq-${ZMQ_VERSION}
|
||||
cd libzmq-${ZMQ_VERSION}
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
@ -25,14 +25,17 @@ if [ "${ZMQ_VERSION}" != "" ] ; then install_zeromq ; fi
|
||||
|
||||
# build cppzmq
|
||||
|
||||
pushd .
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
sudo make -j4 install
|
||||
popd
|
||||
|
||||
# build cppzmq tests
|
||||
# cd tests
|
||||
# mkdir build
|
||||
# cd build
|
||||
# cmake ..
|
||||
# make -j5 test ARGS="-V"
|
||||
cd tests
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest
|
||||
|
1
external/gtest-demo/INFO.md
vendored
Normal file
1
external/gtest-demo/INFO.md
vendored
Normal file
@ -0,0 +1 @@
|
||||
googletest integration into CMake and travis-ci was based on https://github.com/bast/gtest-demo
|
27
external/gtest-demo/LICENSE
vendored
Normal file
27
external/gtest-demo/LICENSE
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright (c) 2015-2018, Radovan Bast
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of gtest-demo nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
44
tests/CMakeLists.txt
Normal file
44
tests/CMakeLists.txt
Normal file
@ -0,0 +1,44 @@
|
||||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
||||
|
||||
project(cppzmq-test CXX)
|
||||
|
||||
# place binaries and libraries according to GNU standards
|
||||
# TODO check if we should do this
|
||||
|
||||
# include(GNUInstallDirs)
|
||||
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# we use this to get code coverage
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
||||
include(cmake/googletest.cmake)
|
||||
fetch_googletest(
|
||||
${PROJECT_SOURCE_DIR}/cmake
|
||||
${PROJECT_BINARY_DIR}/googletest
|
||||
)
|
||||
|
||||
find_package(cppzmq)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_executable(
|
||||
unit_tests
|
||||
example_add.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
unit_tests
|
||||
gtest_main
|
||||
libzmq
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME
|
||||
unit
|
||||
COMMAND
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/unit_tests
|
||||
)
|
20
tests/cmake/googletest-download.cmake
Normal file
20
tests/cmake/googletest-download.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
# code copied from https://crascit.com/2015/07/25/cmake-gtest/
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
project(googletest-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(
|
||||
googletest
|
||||
SOURCE_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-src"
|
||||
BINARY_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-build"
|
||||
GIT_REPOSITORY
|
||||
https://github.com/google/googletest.git
|
||||
GIT_TAG
|
||||
release-1.8.0
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
32
tests/cmake/googletest.cmake
Normal file
32
tests/cmake/googletest.cmake
Normal file
@ -0,0 +1,32 @@
|
||||
# the following code to fetch googletest
|
||||
# is inspired by and adapted after https://crascit.com/2015/07/25/cmake-gtest/
|
||||
# download and unpack googletest at configure time
|
||||
|
||||
macro(fetch_googletest _download_module_path _download_root)
|
||||
set(GOOGLETEST_DOWNLOAD_ROOT ${_download_root})
|
||||
configure_file(
|
||||
${_download_module_path}/googletest-download.cmake
|
||||
${_download_root}/CMakeLists.txt
|
||||
@ONLY
|
||||
)
|
||||
unset(GOOGLETEST_DOWNLOAD_ROOT)
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||
WORKING_DIRECTORY
|
||||
${_download_root}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" --build .
|
||||
WORKING_DIRECTORY
|
||||
${_download_root}
|
||||
)
|
||||
|
||||
# adds the targers: gtest, gtest_main, gmock, gmock_main
|
||||
add_subdirectory(
|
||||
${_download_root}/googletest-src
|
||||
${_download_root}/googletest-build
|
||||
)
|
||||
endmacro()
|
9
tests/example_add.cpp
Normal file
9
tests/example_add.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include <zmq.hpp>
|
||||
|
||||
TEST(create_context, add)
|
||||
{
|
||||
zmq::context_t context;
|
||||
|
||||
|
||||
}
|
7
tests/main.cpp
Normal file
7
tests/main.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user