Skip to content

Commit

Permalink
Merge pull request #178 from aboseley/adam/use-catch2
Browse files Browse the repository at this point in the history
Use catch2 for unit testing
  • Loading branch information
aboseley authored Dec 3, 2021
2 parents febe5f0 + 46f11ed commit 27740d7
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 9,019 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cmake-superbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ ExternalProject_Add(
DEPENDS ${LIBS}
CMAKE_ARGS ${CMAKE_ARGS} -DBUILD_TESTING=YES
SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../..
TEST_COMMAND ctest --repeat-until-fail 3
TEST_BEFORE_INSTALL YES
)
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
os: ubuntu-20.04,
boost_url: system,
zmq_tag: system,
system_packages: "libboost-all-dev libzmq3-dev",
system_packages: "libboost-all-dev libzmq3-dev ",
cc: "gcc",
cxx: "g++",
}
Expand All @@ -54,7 +54,7 @@ jobs:
os: macos-11,
boost_url: system,
zmq_tag: system,
system_packages: "zmq boost",
system_packages: "zmq boost ",
cc: "clang",
cxx: "clang++",
}
Expand Down
8 changes: 1 addition & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ if(NOT AZMQ_NO_TESTS)
enable_testing()
endif()

macro(add_catch_test name)
if (TEST_REPORT_FORMAT)
add_test(NAME ${name} COMMAND ${name} -r ${TEST_REPORT_FORMAT} -o "${name}.test_out.xml")
else()
add_test(NAME ${name} COMMAND ${name})
endif()
endmacro()


if(NOT AZMQ_NO_TESTS)
add_subdirectory(test)
Expand Down
19 changes: 19 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
find_package(Catch2)
if ( NOT Catch2 )
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.7)
FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/contrib)
endif()

link_libraries(Catch2::Catch2)

macro(add_catch_test name)
include(CTest)
include(Catch)
catch_discover_tests(${name})
endmacro()

add_subdirectory(message)
add_subdirectory(context_ops)
add_subdirectory(socket_ops)
Expand Down
2 changes: 1 addition & 1 deletion test/actor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <iostream>

#define CATCH_CONFIG_MAIN
#include "../catch.hpp"
#include <catch2/catch.hpp>

std::array<boost::asio::const_buffer, 2> snd_bufs = {{
boost::asio::buffer("A"),
Expand Down
Loading

0 comments on commit 27740d7

Please sign in to comment.