From 5d104e8744a30a7f4619c0bbbd40c68ba7692217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Thu, 28 Dec 2023 14:34:48 +0100 Subject: [PATCH 1/8] only support boost >= 1.70 This allows to remove all ifdefs that support old boost versions. --- CMakeLists.txt | 8 +------- README.md | 2 +- .../internal/connectors/wire/WireServer.hpp | 10 ---------- src/connectors/wire/WireServer.cpp | 12 ------------ src/drivers/BoostDriver.cpp | 13 ------------- tests/integration/drivers/BoostDriverTest.cpp | 2 -- 6 files changed, 2 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b39f9a46..e1700b86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,13 +111,7 @@ endif() # Boost # -if(MSVC11) - # Boost 1.51 fixed a bug with MSVC11 - message(STATUS "Forcing Boost 1.51+ on MSVC11") - set(BOOST_MIN_VERSION "1.51") -else() - set(BOOST_MIN_VERSION "1.46") -endif() +set(BOOST_MIN_VERSION "1.70") set(Boost_USE_STATIC_RUNTIME OFF) set(CUKE_CORE_BOOST_LIBS system program_options) diff --git a/README.md b/README.md index 0b4cf945..f8dc3f5d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ It relies on a few executables: It relies on a few libraries: -* [Boost](http://www.boost.org/) 1.46 or later (1.51+ on Windows). +* [Boost](http://www.boost.org/) 1.70. Required libraries: *system* and *program_options*. Optional library for Boost Test driver: *test*. * [GTest](http://code.google.com/p/googletest/) 1.6 or later. diff --git a/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp b/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp index bd2a579b..88d22968 100644 --- a/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp +++ b/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp @@ -31,15 +31,6 @@ class CUCUMBER_CPP_EXPORT SocketServer { const ProtocolHandler* protocolHandler; boost::asio::io_service ios; -#if BOOST_VERSION <= 106500 - template - void doListen( - boost::asio::basic_socket_acceptor& acceptor, - const typename Protocol::endpoint& endpoint - ); - template - void doAcceptOnce(boost::asio::basic_socket_acceptor& acceptor); -#else template void doListen( boost::asio::basic_socket_acceptor& acceptor, @@ -47,7 +38,6 @@ class CUCUMBER_CPP_EXPORT SocketServer { ); template void doAcceptOnce(boost::asio::basic_socket_acceptor& acceptor); -#endif void processStream(std::iostream& stream); }; diff --git a/src/connectors/wire/WireServer.cpp b/src/connectors/wire/WireServer.cpp index df88e5df..4840593e 100644 --- a/src/connectors/wire/WireServer.cpp +++ b/src/connectors/wire/WireServer.cpp @@ -15,17 +15,10 @@ SocketServer::SocketServer(const ProtocolHandler* protocolHandler) : ios() { } -#if BOOST_VERSION <= 106500 -template -void SocketServer::doListen( - basic_socket_acceptor& acceptor, const typename Protocol::endpoint& endpoint -) { -#else template void SocketServer::doListen( basic_socket_acceptor& acceptor, const typename Protocol::endpoint& endpoint ) { -#endif if (acceptor.is_open()) throw boost::system::system_error(boost::asio::error::already_open); acceptor.open(endpoint.protocol()); @@ -34,13 +27,8 @@ void SocketServer::doListen( acceptor.listen(1); } -#if BOOST_VERSION <= 106500 -template -void SocketServer::doAcceptOnce(basic_socket_acceptor& acceptor) { -#else template void SocketServer::doAcceptOnce(basic_socket_acceptor& acceptor) { -#endif typename Protocol::iostream stream; acceptor.accept(*stream.rdbuf()); processStream(stream); diff --git a/src/drivers/BoostDriver.cpp b/src/drivers/BoostDriver.cpp index 6fa75ade..de5310cc 100644 --- a/src/drivers/BoostDriver.cpp +++ b/src/drivers/BoostDriver.cpp @@ -45,11 +45,7 @@ class CukeBoostLogInterceptor : public ::boost::unit_test::unit_test_log_formatt // Formatter void log_start(std::ostream&, counter_t /*test_cases_amount*/) override{}; void log_finish(std::ostream&) override{}; -#if BOOST_VERSION >= 107000 void log_build_info(std::ostream&, bool /*log_build_info*/) override{}; -#else - void log_build_info(std::ostream&) override{}; -#endif void test_unit_start(std::ostream&, test_unit const& /*tu*/) override{}; void test_unit_finish(std::ostream&, test_unit const& /*tu*/, unsigned long /*elapsed*/) @@ -67,17 +63,10 @@ class CukeBoostLogInterceptor : public ::boost::unit_test::unit_test_log_formatt void entry_context_start(std::ostream&, log_level /*l*/) override { } -#if BOOST_VERSION >= 106500 void log_entry_context(std::ostream&, log_level /*l*/, const_string /*value*/) override { } void entry_context_finish(std::ostream&, log_level /*l*/) override { } -#else - void log_entry_context(std::ostream&, const_string /*value*/) override { - } - void entry_context_finish(std::ostream&) override { - } -#endif private: std::stringstream description; @@ -121,9 +110,7 @@ void BoostStep::initBoostTest() { char dummyArg[] = "dummy"; char* argv[] = {dummyArg}; framework::init(&boost_test_init, argc, argv); -#if BOOST_VERSION >= 105900 framework::finalize_setup_phase(); -#endif logInterceptor = new CukeBoostLogInterceptor; ::boost::unit_test::unit_test_log.set_formatter(logInterceptor); diff --git a/tests/integration/drivers/BoostDriverTest.cpp b/tests/integration/drivers/BoostDriverTest.cpp index 676f5d30..ebaacc79 100644 --- a/tests/integration/drivers/BoostDriverTest.cpp +++ b/tests/integration/drivers/BoostDriverTest.cpp @@ -26,7 +26,6 @@ THEN(PENDING_MATCHER_2) { using namespace cucumber::internal; -#if BOOST_VERSION >= 105900 namespace boost { namespace unit_test { namespace framework { @@ -36,7 +35,6 @@ bool is_initialized() { } } } -#endif class BoostStepDouble : public BoostStep { public: From 7078e0c06c2a7b09fdcb119076f6afd10d829fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Thu, 28 Dec 2023 14:41:37 +0100 Subject: [PATCH 2/8] remove special code for no longer supported C++ standard --- .../internal/RegistrationMacros.hpp | 26 ++++++-------- .../internal/utils/IndexSequence.hpp | 35 +------------------ 2 files changed, 11 insertions(+), 50 deletions(-) diff --git a/include/cucumber-cpp/internal/RegistrationMacros.hpp b/include/cucumber-cpp/internal/RegistrationMacros.hpp index 1759a66c..0059d950 100644 --- a/include/cucumber-cpp/internal/RegistrationMacros.hpp +++ b/include/cucumber-cpp/internal/RegistrationMacros.hpp @@ -1,12 +1,6 @@ #ifndef CUKE_REGISTRATIONMACROS_HPP_ #define CUKE_REGISTRATIONMACROS_HPP_ -#if __cplusplus >= 201103L - #define CUKE_OVERRIDE override -#else - #define CUKE_OVERRIDE -#endif - // ************************************************************************** // // ************** OBJECT NAMING MACROS ************** // // ************************************************************************** // @@ -27,16 +21,16 @@ // ************** CUKE OBJECTS ************** // // ************************************************************************** // -#define CUKE_OBJECT_(class_name, parent_class, registration_fn, args) \ - class class_name : public parent_class { \ - public: \ - void body() CUKE_OVERRIDE { return invokeWithArgs(*this, &class_name::bodyWithArgs); } \ - void bodyWithArgs args; \ - \ - private: \ - static const int cukeRegId; \ - }; \ - const int class_name ::cukeRegId = registration_fn; \ +#define CUKE_OBJECT_(class_name, parent_class, registration_fn, args) \ + class class_name : public parent_class { \ + public: \ + void body() override { return invokeWithArgs(*this, &class_name::bodyWithArgs); } \ + void bodyWithArgs args; \ + \ + private: \ + static const int cukeRegId; \ + }; \ + const int class_name ::cukeRegId = registration_fn; \ void class_name ::bodyWithArgs args /**/ #endif /* CUKE_REGISTRATIONMACROS_HPP_ */ diff --git a/include/cucumber-cpp/internal/utils/IndexSequence.hpp b/include/cucumber-cpp/internal/utils/IndexSequence.hpp index 6909235d..096192d4 100644 --- a/include/cucumber-cpp/internal/utils/IndexSequence.hpp +++ b/include/cucumber-cpp/internal/utils/IndexSequence.hpp @@ -5,46 +5,13 @@ #ifndef BOOST_NO_VARIADIC_TEMPLATES - #if __cplusplus < 201402L && !(_MSC_VER > 1800) - #include // for std::size_t - #else - #include - #endif + #include namespace cucumber { namespace internal { - #if __cplusplus < 201402L && !(_MSC_VER > 1800) -// Based on https://stackoverflow.com/questions/17424477/implementation-c14-make-integer-sequence - -template -struct index_sequence { - typedef index_sequence type; -}; - -template -struct concat_index_sequence; - -template -struct concat_index_sequence, index_sequence> - : public index_sequence {}; - -template -struct make_index_sequence : public concat_index_sequence< - typename make_index_sequence::type, - typename make_index_sequence::type> {}; - -template<> -struct make_index_sequence<0> : public index_sequence<> {}; -template<> -struct make_index_sequence<1> : public index_sequence<0> {}; - -template -using index_sequence_for = make_index_sequence; - #else using ::std::index_sequence; using ::std::index_sequence_for; - #endif } } From cb771fbe5d1a41d7d0f6e59fcc48903503e72cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Thu, 28 Dec 2023 14:54:50 +0100 Subject: [PATCH 3/8] remove special code to support C++11 Don't use the macros - BOOST_NO_DELETED_FUNCTIONS - BOOST_NO_EXPLICIT_CONVERSION_OPERATORS - BOOST_NO_VARIADIC_TEMPLATES anymore because all compiler support those features now (https://en.cppreference.com/w/cpp/compiler_support/11). --- .../internal/RegistrationMacros.hpp | 2 ++ .../internal/hook/HookRegistrar.hpp | 8 +----- .../internal/step/StepManager.hpp | 26 +++---------------- .../internal/utils/IndexSequence.hpp | 8 +----- tests/unit/CukeCommandsTest.cpp | 4 --- 5 files changed, 7 insertions(+), 41 deletions(-) diff --git a/include/cucumber-cpp/internal/RegistrationMacros.hpp b/include/cucumber-cpp/internal/RegistrationMacros.hpp index 0059d950..7de752c2 100644 --- a/include/cucumber-cpp/internal/RegistrationMacros.hpp +++ b/include/cucumber-cpp/internal/RegistrationMacros.hpp @@ -1,6 +1,8 @@ #ifndef CUKE_REGISTRATIONMACROS_HPP_ #define CUKE_REGISTRATIONMACROS_HPP_ +#include + // ************************************************************************** // // ************** OBJECT NAMING MACROS ************** // // ************************************************************************** // diff --git a/include/cucumber-cpp/internal/hook/HookRegistrar.hpp b/include/cucumber-cpp/internal/hook/HookRegistrar.hpp index adafccc3..4e3481ba 100644 --- a/include/cucumber-cpp/internal/hook/HookRegistrar.hpp +++ b/include/cucumber-cpp/internal/hook/HookRegistrar.hpp @@ -6,9 +6,7 @@ #include "../Scenario.hpp" #include "../step/StepManager.hpp" -#include #include - #include namespace cucumber { @@ -102,11 +100,7 @@ class CUCUMBER_CPP_EXPORT HookRegistrar { private: // We're a singleton so don't allow instances - HookRegistrar() -#ifndef BOOST_NO_DELETED_FUNCTIONS - = delete -#endif - ; + HookRegistrar() = delete; }; class CUCUMBER_CPP_EXPORT StepCallChain { diff --git a/include/cucumber-cpp/internal/step/StepManager.hpp b/include/cucumber-cpp/internal/step/StepManager.hpp index 25f2d616..ee9875d2 100644 --- a/include/cucumber-cpp/internal/step/StepManager.hpp +++ b/include/cucumber-cpp/internal/step/StepManager.hpp @@ -6,13 +6,8 @@ #include #include #include - -#include #include - -#ifndef BOOST_NO_VARIADIC_TEMPLATES - #include -#endif +#include #include #include "../Table.hpp" @@ -43,10 +38,7 @@ class CUCUMBER_CPP_EXPORT MatchResult { const match_results_type& getResultSet(); void addMatch(SingleStepMatch match); -#ifndef BOOST_NO_EXPLICIT_CONVERSION_OPERATORS - explicit -#endif - operator bool() const; + explicit operator bool() const; private: match_results_type resultSet; @@ -139,13 +131,6 @@ class CUCUMBER_CPP_EXPORT BasicStep { const T getInvokeArg(); const InvokeArgs* getArgs(); -#ifdef BOOST_NO_VARIADIC_TEMPLATES - // Special case for zero arguments, only thing we bother to support on C++98 - template - static R invokeWithArgs(Derived& that, R (Derived::*f)()) { - return (that.*f)(); - } -#else template static R invokeWithIndexedArgs(Derived& that, R (Derived::*f)(Args...), index_sequence) { return (that.*f)(that.pArgs->template getInvokeArg::type>(N)...); @@ -156,7 +141,6 @@ class CUCUMBER_CPP_EXPORT BasicStep { that.currentArgIndex = sizeof...(Args); return invokeWithIndexedArgs(that, f, index_sequence_for{}); } -#endif private: // FIXME: awful hack because of Boost::Test @@ -188,11 +172,7 @@ class CUCUMBER_CPP_EXPORT StepManager { private: // We're a singleton so don't allow instances - StepManager() -#ifndef BOOST_NO_DELETED_FUNCTIONS - = delete -#endif - ; + StepManager() = delete; }; static inline std::string toSourceString(const char* filePath, const int line) { diff --git a/include/cucumber-cpp/internal/utils/IndexSequence.hpp b/include/cucumber-cpp/internal/utils/IndexSequence.hpp index 096192d4..07139e9a 100644 --- a/include/cucumber-cpp/internal/utils/IndexSequence.hpp +++ b/include/cucumber-cpp/internal/utils/IndexSequence.hpp @@ -1,11 +1,7 @@ #ifndef CUKE_INDEXSEQ_HPP_ #define CUKE_INDEXSEQ_HPP_ -#include - -#ifndef BOOST_NO_VARIADIC_TEMPLATES - - #include +#include namespace cucumber { namespace internal { @@ -16,6 +12,4 @@ using ::std::index_sequence_for; } } -#endif /* !BOOST_NO_VARIADIC_TEMPLATES */ - #endif /* CUKE_INDEXSEQ_HPP_ */ diff --git a/tests/unit/CukeCommandsTest.cpp b/tests/unit/CukeCommandsTest.cpp index 6449292d..0769c13a 100644 --- a/tests/unit/CukeCommandsTest.cpp +++ b/tests/unit/CukeCommandsTest.cpp @@ -3,8 +3,6 @@ #include #include "utils/CukeCommandsFixture.hpp" -#include - using namespace cucumber::internal; using std::string; @@ -77,7 +75,6 @@ class CheckAllParametersWithMacro : public CheckAllParameters { } }; -#ifndef BOOST_NO_VARIADIC_TEMPLATES class CheckAllParametersWithFuncArgs : public CheckAllParameters { public: void bodyWithArgs( @@ -101,7 +98,6 @@ TEST_F(CukeCommandsTest, invokeHandlesParametersWithFuncArgs) { // The real test is in TestClass::body() runStepBodyTest(); } -#endif TEST_F(CukeCommandsTest, matchesCorrectly) { addStepWithMatcher(STATIC_MATCHER); From ddc4bd631057df5abef27411dae9970ab14f7f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Thu, 28 Dec 2023 15:58:31 +0100 Subject: [PATCH 4/8] copy JOIN macro from boost Remove dependency to boost. --- include/cucumber-cpp/internal/RegistrationMacros.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/cucumber-cpp/internal/RegistrationMacros.hpp b/include/cucumber-cpp/internal/RegistrationMacros.hpp index 7de752c2..4f9c88cf 100644 --- a/include/cucumber-cpp/internal/RegistrationMacros.hpp +++ b/include/cucumber-cpp/internal/RegistrationMacros.hpp @@ -1,22 +1,25 @@ #ifndef CUKE_REGISTRATIONMACROS_HPP_ #define CUKE_REGISTRATIONMACROS_HPP_ -#include - // ************************************************************************** // // ************** OBJECT NAMING MACROS ************** // // ************************************************************************** // +// from https://www.boost.org/doc/libs/1_84_0/boost/config/helper_macros.hpp +#define CUKE_JOIN(X, Y) CUKE_DO_JOIN(X, Y) +#define CUKE_DO_JOIN(X, Y) CUKE_DO_JOIN2(X, Y) +#define CUKE_DO_JOIN2(X, Y) X##Y + #ifndef CUKE_OBJECT_PREFIX #define CUKE_OBJECT_PREFIX CukeObject #endif #ifdef __COUNTER__ - #define CUKE_GEN_OBJECT_NAME_ BOOST_JOIN(CUKE_OBJECT_PREFIX, __COUNTER__) + #define CUKE_GEN_OBJECT_NAME_ CUKE_JOIN(CUKE_OBJECT_PREFIX, __COUNTER__) #else // Use a counter to be incremented every time cucumber-cpp is included // in case this does not suffice (possible with multiple files only) - #define CUKE_GEN_OBJECT_NAME_ BOOST_JOIN(CUKE_OBJECT_PREFIX, __LINE__) + #define CUKE_GEN_OBJECT_NAME_ CUKE_JOIN(CUKE_OBJECT_PREFIX, __LINE__) #endif // ************************************************************************** // From 8a0d16b8f59dd1c9d75045aa016d9ce235257311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Thu, 28 Dec 2023 17:28:24 +0100 Subject: [PATCH 5/8] add version info to cucumber-cpp-main --- cmake/modules/GitVersion.cmake | 29 +++++++++++++++++++++++++++++ src/CMakeLists.txt | 7 +++++++ src/main.cpp | 6 ++++++ 3 files changed, 42 insertions(+) create mode 100644 cmake/modules/GitVersion.cmake diff --git a/cmake/modules/GitVersion.cmake b/cmake/modules/GitVersion.cmake new file mode 100644 index 00000000..b5c4e756 --- /dev/null +++ b/cmake/modules/GitVersion.cmake @@ -0,0 +1,29 @@ +function(git_get_version VERSION_VARIABLE) + find_program(GIT_EXECUTABLE git) + + if(NOT GIT_EXECUTABLE) + message(FATAL_ERROR "Git not found. Please install Git and make sure it is in your system's PATH.") + endif() + + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --always --dirty + OUTPUT_VARIABLE VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + ERROR_VARIABLE GIT_DESCRIBE_ERROR + RESULT_VARIABLE GIT_DESCRIBE_RESULT + ) + + if(NOT GIT_DESCRIBE_RESULT EQUAL 0) + message(FATAL_ERROR "Error running 'git describe': ${GIT_DESCRIBE_ERROR}") + endif() + + string(LENGTH "${VERSION_STRING}" VERSION_STRING_LENGTH) + string(SUBSTRING "${VERSION_STRING}" 0 1 FIRST_CHARACTER) + + if("${FIRST_CHARACTER}" STREQUAL "v") + string(SUBSTRING "${VERSION_STRING}" 1 ${VERSION_STRING_LENGTH} VERSION_STRING) + endif() + + set(${VERSION_VARIABLE} ${VERSION_STRING} PARENT_SCOPE) +endfunction() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 547a5078..3579e695 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ include(GenerateExportHeader) find_package(nlohmann_json 3.10.5 REQUIRED) +include(../cmake/modules/GitVersion.cmake) set(CUKE_SOURCES drivers/GenericDriver.cpp @@ -123,6 +124,12 @@ foreach(TARGET endif(MINGW) endforeach() +git_get_version(CUKE_VERSION) +message(STATUS "Version: ${CUKE_VERSION}") +target_compile_definitions(cucumber-cpp PRIVATE + CUKE_VERSION="${CUKE_VERSION}" +) + target_link_libraries(cucumber-cpp PRIVATE Boost::program_options diff --git a/src/main.cpp b/src/main.cpp index 18656715..44031d1f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,6 +47,7 @@ int CUCUMBER_CPP_EXPORT main(int argc, char** argv) { boost::program_options::options_description optionDescription("Allowed options"); optionDescription.add_options()("help,h", "help for cucumber-cpp")( "verbose,v", "verbose output" + )("version", "version of cucumber-cpp" )("listen,l", value(), "listening address of wireserver" )("port,p", value(), @@ -68,6 +69,11 @@ int CUCUMBER_CPP_EXPORT main(int argc, char** argv) { exit(1); } + if (optionVariableMap.count("version")) { + std::cout << CUKE_VERSION << std::endl; + exit(0); + } + std::string listenHost("127.0.0.1"); if (optionVariableMap.count("listen")) { listenHost = optionVariableMap["listen"].as(); From b688cf41647803daa8a7656595b0d1bcbabf2310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Thu, 28 Dec 2023 17:33:05 +0100 Subject: [PATCH 6/8] use TCLAP to parse program options Remove dependency to boost::program_options. --- .github/workflows/run-all.yml | 2 +- CMakeLists.txt | 9 +--- README.md | 3 +- cmake/modules/FindTCLAP.cmake | 10 +++++ src/CMakeLists.txt | 6 +-- src/main.cpp | 77 +++++++++++++++-------------------- 6 files changed, 47 insertions(+), 60 deletions(-) create mode 100644 cmake/modules/FindTCLAP.cmake diff --git a/.github/workflows/run-all.yml b/.github/workflows/run-all.yml index 7c6aeef0..24a9d20e 100644 --- a/.github/workflows/run-all.yml +++ b/.github/workflows/run-all.yml @@ -22,9 +22,9 @@ jobs: g++ \ gcovr \ git \ - libboost-program-options-dev \ libboost-system-dev \ libboost-test-dev \ + libtclap-dev \ make \ ninja-build \ nlohmann-json3-dev \ diff --git a/CMakeLists.txt b/CMakeLists.txt index e1700b86..1f383185 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ endif() set(BOOST_MIN_VERSION "1.70") set(Boost_USE_STATIC_RUNTIME OFF) -set(CUKE_CORE_BOOST_LIBS system program_options) +set(CUKE_CORE_BOOST_LIBS system) if(CUKE_ENABLE_BOOST_TEST) # "An external test runner utility is required to link with dynamic library" (Boost User's Guide) set(Boost_USE_STATIC_LIBS OFF) @@ -155,13 +155,6 @@ if(Boost_SYSTEM_LIBRARY AND NOT TARGET Boost::system) ) endif() endif() -if(Boost_PROGRAM_OPTIONS_LIBRARY AND NOT TARGET Boost::program_options) - add_library(Boost::program_options ${LIBRARY_TYPE} IMPORTED) - set_target_properties(Boost::program_options PROPERTIES - "IMPORTED_LOCATION" "${Boost_PROGRAM_OPTIONS_LIBRARY}" - "INTERFACE_LINK_LIBRARIES" "Boost::boost" - ) -endif() if(Boost_UNIT_TEST_FRAMEWORK_LIBRARY AND NOT TARGET Boost::unit_test_framework) add_library(Boost::unit_test_framework ${LIBRARY_TYPE} IMPORTED) set_target_properties(Boost::unit_test_framework PROPERTIES diff --git a/README.md b/README.md index f8dc3f5d..b7a43719 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ It relies on a few executables: It relies on a few libraries: * [Boost](http://www.boost.org/) 1.70. - Required libraries: *system* and *program_options*. + Required libraries: *system*. Optional library for Boost Test driver: *test*. * [GTest](http://code.google.com/p/googletest/) 1.6 or later. Optional for the GTest driver. By default downloaded and built by CMake. @@ -31,6 +31,7 @@ It relies on a few libraries: Optional for the internal test suite. By default downloaded and built by CMake. * [nlohmann-json](https://github.com/nlohmann/json) 3.10.5 or later. * [Qt 4 or 5](http://qt-project.org/). Optional for the CalcQt example and QtTest driver (only Qt 5). +* [TCLAP](https://tclap.sourceforge.net/) 1.2.5 or later. It might work with earlier versions of the libraries, but it was not tested with them. See the [CI scripts](.github/workflows/run-all.yml) for details about dependency installation. diff --git a/cmake/modules/FindTCLAP.cmake b/cmake/modules/FindTCLAP.cmake new file mode 100644 index 00000000..4a2e1a91 --- /dev/null +++ b/cmake/modules/FindTCLAP.cmake @@ -0,0 +1,10 @@ +find_path(TCLAP_INCLUDE_DIR tclap/CmdLine.h) + +if (TCLAP_INCLUDE_DIR) + set(TCLAP_FOUND TRUE) +else () + set(TCLAP_FOUND FALSE) +endif () + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCLAP REQUIRED_VARS TCLAP_INCLUDE_DIR) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3579e695..89db8c29 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ include(GenerateExportHeader) find_package(nlohmann_json 3.10.5 REQUIRED) +find_package(TCLAP REQUIRED) include(../cmake/modules/GitVersion.cmake) set(CUKE_SOURCES @@ -130,11 +131,6 @@ target_compile_definitions(cucumber-cpp PRIVATE CUKE_VERSION="${CUKE_VERSION}" ) -target_link_libraries(cucumber-cpp - PRIVATE - Boost::program_options -) - include(GNUInstallDirs) install(DIRECTORY ${CUKE_INCLUDE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install( diff --git a/src/main.cpp b/src/main.cpp index 44031d1f..fd7006fa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include namespace { @@ -43,58 +43,45 @@ void acceptWireProtocol( } int CUCUMBER_CPP_EXPORT main(int argc, char** argv) { - using boost::program_options::value; - boost::program_options::options_description optionDescription("Allowed options"); - optionDescription.add_options()("help,h", "help for cucumber-cpp")( - "verbose,v", "verbose output" - )("version", "version of cucumber-cpp" - )("listen,l", value(), "listening address of wireserver" - )("port,p", - value(), - "listening port of wireserver, use '0' (zero) to select an ephemeral port") -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) - ("unix,u", - value(), - "listening unix socket of wireserver (disables listening on port)") -#endif - ; - boost::program_options::variables_map optionVariableMap; - boost::program_options::store( - boost::program_options::parse_command_line(argc, argv, optionDescription), optionVariableMap - ); - boost::program_options::notify(optionVariableMap); - - if (optionVariableMap.count("help")) { - std::cerr << optionDescription << std::endl; - exit(1); - } + TCLAP::CmdLine cmd("C++ Cucumber wireserver", ' ', CUKE_VERSION); - if (optionVariableMap.count("version")) { - std::cout << CUKE_VERSION << std::endl; - exit(0); - } + TCLAP::SwitchArg verboseArg("v", "verbose", "Verbose output", cmd, false); + TCLAP::ValueArg listenArg( + "l", "listen", "Listening address of wireserver", false, "127.0.0.1", "string" + ); + cmd.add(listenArg); + TCLAP::ValueArg portArg( + "p", + "port", + "Listening port of wireserver, use '0' (zero) to select an ephemeral port", + false, + 3902, + "int" + ); + cmd.add(portArg); - std::string listenHost("127.0.0.1"); - if (optionVariableMap.count("listen")) { - listenHost = optionVariableMap["listen"].as(); - } +#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) + TCLAP::ValueArg unixArg( + "u", + "unix", + "Listening unix socket of wireserver (disables listening on port)", + false, + "", + "string" + ); + cmd.add(unixArg); +#endif - int port = 3902; - if (optionVariableMap.count("port")) { - port = optionVariableMap["port"].as(); - } + cmd.parse(argc, argv); std::string unixPath; + std::string listenHost = listenArg.getValue(); + int port = portArg.getValue(); #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) - if (optionVariableMap.count("unix")) { - unixPath = optionVariableMap["unix"].as(); - } + unixPath = unixArg.getValue(); #endif - bool verbose = false; - if (optionVariableMap.count("verbose")) { - verbose = true; - } + bool verbose = verboseArg.getValue(); try { acceptWireProtocol(listenHost, port, unixPath, verbose); From 9b7015505e40a05c5ad80fa6f08aa5e94bff60f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Thu, 28 Dec 2023 23:09:41 +0100 Subject: [PATCH 7/8] throw std::system_error instead of boost::system::system_error --- include/cucumber-cpp/internal/connectors/wire/WireServer.hpp | 4 ++-- src/connectors/wire/WireServer.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp b/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp index 88d22968..5da7a8e8 100644 --- a/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp +++ b/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp @@ -70,7 +70,7 @@ class CUCUMBER_CPP_EXPORT TCPSocketServer : public SocketServer { * Endpoint (IP address and port number) that this server is currently * listening on. * - * @throw boost::system::system_error when not listening on any socket or + * @throw std::system_error when not listening on any socket or * the endpoint cannot be determined. */ boost::asio::ip::tcp::endpoint listenEndpoint() const; @@ -100,7 +100,7 @@ class CUCUMBER_CPP_EXPORT UnixSocketServer : public SocketServer { /** * Port number that this server is currently listening on. * - * @throw boost::system::system_error when not listening on any socket or + * @throw std::system_error when not listening on any socket or * the endpoint cannot be determined. */ boost::asio::local::stream_protocol::endpoint listenEndpoint() const; diff --git a/src/connectors/wire/WireServer.cpp b/src/connectors/wire/WireServer.cpp index 4840593e..0b6089df 100644 --- a/src/connectors/wire/WireServer.cpp +++ b/src/connectors/wire/WireServer.cpp @@ -20,7 +20,7 @@ void SocketServer::doListen( basic_socket_acceptor& acceptor, const typename Protocol::endpoint& endpoint ) { if (acceptor.is_open()) - throw boost::system::system_error(boost::asio::error::already_open); + throw std::system_error(asio::error::already_open); acceptor.open(endpoint.protocol()); acceptor.set_option(typename Protocol::acceptor::reuse_address(true)); acceptor.bind(endpoint); From d131ae3951b9aeb03dd787bf6fee4a06a81c1f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Fri, 29 Dec 2023 20:46:36 +0100 Subject: [PATCH 8/8] use asio without boost This removes the last dependency to boost (except the boost test driver). --- .github/workflows/run-all.yml | 2 +- CMakeLists.txt | 48 +------------------ README.md | 5 +- cmake/modules/FindAsio.cmake | 10 ++++ .../internal/connectors/wire/WireServer.hpp | 21 ++++---- src/CMakeLists.txt | 3 +- src/connectors/wire/WireServer.cpp | 24 ++++------ src/main.cpp | 10 ++-- tests/integration/WireServerTest.cpp | 22 ++++----- 9 files changed, 47 insertions(+), 98 deletions(-) create mode 100644 cmake/modules/FindAsio.cmake diff --git a/.github/workflows/run-all.yml b/.github/workflows/run-all.yml index 24a9d20e..f0b66c91 100644 --- a/.github/workflows/run-all.yml +++ b/.github/workflows/run-all.yml @@ -22,7 +22,7 @@ jobs: g++ \ gcovr \ git \ - libboost-system-dev \ + libasio-dev \ libboost-test-dev \ libtclap-dev \ make \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f383185..b93fd492 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ endif() project(Cucumber-Cpp) option(BUILD_SHARED_LIBS "Generate shared libraries" OFF) -option(CUKE_USE_STATIC_BOOST "Statically link Boost (except boost::test)" ${WIN32}) option(CUKE_USE_STATIC_GTEST "Statically link Google Test" ON) option(CUKE_ENABLE_BOOST_TEST "Enable Boost.Test framework" ON) option(CUKE_ENABLE_EXAMPLES "Build examples" OFF) @@ -111,56 +110,11 @@ endif() # Boost # -set(BOOST_MIN_VERSION "1.70") - set(Boost_USE_STATIC_RUNTIME OFF) -set(CUKE_CORE_BOOST_LIBS system) if(CUKE_ENABLE_BOOST_TEST) # "An external test runner utility is required to link with dynamic library" (Boost User's Guide) - set(Boost_USE_STATIC_LIBS OFF) set(CMAKE_CXX_FLAGS "-DBOOST_TEST_DYN_LINK ${CMAKE_CXX_FLAGS}") - find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS unit_test_framework) -endif() - -if(CUKE_USE_STATIC_BOOST) - set(Boost_USE_STATIC_LIBS ON) - find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS ${CUKE_CORE_BOOST_LIBS} REQUIRED) -else() - set(CMAKE_CXX_FLAGS "-DBOOST_ALL_DYN_LINK ${CMAKE_CXX_FLAGS}") - set(Boost_USE_STATIC_LIBS OFF) - find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS ${CUKE_CORE_BOOST_LIBS} REQUIRED) -endif() - -# Create import targets for CMake versions older than 3.5 (actually older FindBoost.cmake) -if(Boost_USE_STATIC_LIBS) - set(LIBRARY_TYPE STATIC) -else() - # Just because we don't ask for static doesn't mean we're not getting static - set(LIBRARY_TYPE UNKNOWN) -endif() -if(Boost_INCLUDE_DIRS AND NOT TARGET Boost::boost) - add_library(Boost::boost INTERFACE IMPORTED) - set_target_properties(Boost::boost PROPERTIES - "INTERFACE_INCLUDE_DIRECTORIES" "${Boost_INCLUDE_DIRS}") -endif() -if(Boost_SYSTEM_LIBRARY AND NOT TARGET Boost::system) - add_library(Boost::system ${LIBRARY_TYPE} IMPORTED) - set_target_properties(Boost::system PROPERTIES - "IMPORTED_LOCATION" "${Boost_SYSTEM_LIBRARY}" - "INTERFACE_LINK_LIBRARIES" "Boost::boost" - ) - if(Boost_USE_STATIC_LIBS) - set_target_properties(Boost::system PROPERTIES - "COMPILE_DEFINITIONS" BOOST_ERROR_CODE_HEADER_ONLY=1 - ) - endif() -endif() -if(Boost_UNIT_TEST_FRAMEWORK_LIBRARY AND NOT TARGET Boost::unit_test_framework) - add_library(Boost::unit_test_framework ${LIBRARY_TYPE} IMPORTED) - set_target_properties(Boost::unit_test_framework PROPERTIES - "IMPORTED_LOCATION" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}" - "INTERFACE_LINK_LIBRARIES" "Boost::boost" - ) + find_package(Boost 1.70 COMPONENTS unit_test_framework) endif() # diff --git a/README.md b/README.md index b7a43719..6741f214 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,8 @@ It relies on a few executables: It relies on a few libraries: -* [Boost](http://www.boost.org/) 1.70. - Required libraries: *system*. - Optional library for Boost Test driver: *test*. +* [Asio](https://think-async.com/Asio/) 1.18.1 or later. +* [Boost.Test](http://www.boost.org/) 1.70. Optional for the Boost Test driver. * [GTest](http://code.google.com/p/googletest/) 1.6 or later. Optional for the GTest driver. By default downloaded and built by CMake. * [GMock](http://code.google.com/p/googlemock/) 1.6 or later. diff --git a/cmake/modules/FindAsio.cmake b/cmake/modules/FindAsio.cmake new file mode 100644 index 00000000..682b7695 --- /dev/null +++ b/cmake/modules/FindAsio.cmake @@ -0,0 +1,10 @@ +find_path(ASIO_INCLUDE_DIR asio.hpp) + +if (ASIO_INCLUDE_DIR) + set(ASIO_FOUND TRUE) +else () + set(ASIO_FOUND FALSE) +endif () + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Asio REQUIRED_VARS ASIO_INCLUDE_DIR) diff --git a/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp b/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp index 5da7a8e8..19c48382 100644 --- a/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp +++ b/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp @@ -6,7 +6,7 @@ #include -#include +#include namespace cucumber { namespace internal { @@ -29,15 +29,14 @@ class CUCUMBER_CPP_EXPORT SocketServer { protected: const ProtocolHandler* protocolHandler; - boost::asio::io_service ios; + asio::io_service ios; template void doListen( - boost::asio::basic_socket_acceptor& acceptor, - const typename Protocol::endpoint& endpoint + asio::basic_socket_acceptor& acceptor, const typename Protocol::endpoint& endpoint ); template - void doAcceptOnce(boost::asio::basic_socket_acceptor& acceptor); + void doAcceptOnce(asio::basic_socket_acceptor& acceptor); void processStream(std::iostream& stream); }; @@ -64,7 +63,7 @@ class CUCUMBER_CPP_EXPORT TCPSocketServer : public SocketServer { /** * Bind and listen to a TCP port on the given endpoint */ - void listen(const boost::asio::ip::tcp::endpoint endpoint); + void listen(const asio::ip::tcp::endpoint endpoint); /** * Endpoint (IP address and port number) that this server is currently @@ -73,15 +72,15 @@ class CUCUMBER_CPP_EXPORT TCPSocketServer : public SocketServer { * @throw std::system_error when not listening on any socket or * the endpoint cannot be determined. */ - boost::asio::ip::tcp::endpoint listenEndpoint() const; + asio::ip::tcp::endpoint listenEndpoint() const; void acceptOnce() override; private: - boost::asio::ip::tcp::acceptor acceptor; + asio::ip::tcp::acceptor acceptor; }; -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +#if defined(ASIO_HAS_LOCAL_SOCKETS) /** * Socket server that calls a protocol handler line by line */ @@ -103,14 +102,14 @@ class CUCUMBER_CPP_EXPORT UnixSocketServer : public SocketServer { * @throw std::system_error when not listening on any socket or * the endpoint cannot be determined. */ - boost::asio::local::stream_protocol::endpoint listenEndpoint() const; + asio::local::stream_protocol::endpoint listenEndpoint() const; void acceptOnce() override; ~UnixSocketServer() override; private: - boost::asio::local::stream_protocol::acceptor acceptor; + asio::local::stream_protocol::acceptor acceptor; }; #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 89db8c29..20003e7e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ include(GenerateExportHeader) find_package(nlohmann_json 3.10.5 REQUIRED) +find_package(Asio REQUIRED) find_package(TCLAP REQUIRED) include(../cmake/modules/GitVersion.cmake) @@ -107,8 +108,6 @@ foreach(TARGET $/include> ) target_link_libraries(${TARGET} - PUBLIC - Boost::boost PRIVATE ${CUKE_EXTRA_PRIVATE_LIBRARIES} ) diff --git a/src/connectors/wire/WireServer.cpp b/src/connectors/wire/WireServer.cpp index 0b6089df..64042660 100644 --- a/src/connectors/wire/WireServer.cpp +++ b/src/connectors/wire/WireServer.cpp @@ -4,12 +4,6 @@ namespace cucumber { namespace internal { -using namespace boost::asio; -using namespace boost::asio::ip; -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) -using namespace boost::asio::local; -#endif - SocketServer::SocketServer(const ProtocolHandler* protocolHandler) : protocolHandler(protocolHandler), ios() { @@ -17,7 +11,7 @@ SocketServer::SocketServer(const ProtocolHandler* protocolHandler) : template void SocketServer::doListen( - basic_socket_acceptor& acceptor, const typename Protocol::endpoint& endpoint + asio::basic_socket_acceptor& acceptor, const typename Protocol::endpoint& endpoint ) { if (acceptor.is_open()) throw std::system_error(asio::error::already_open); @@ -28,7 +22,7 @@ void SocketServer::doListen( } template -void SocketServer::doAcceptOnce(basic_socket_acceptor& acceptor) { +void SocketServer::doAcceptOnce(asio::basic_socket_acceptor& acceptor) { typename Protocol::iostream stream; acceptor.accept(*stream.rdbuf()); processStream(stream); @@ -47,15 +41,15 @@ TCPSocketServer::TCPSocketServer(const ProtocolHandler* protocolHandler) : } void TCPSocketServer::listen(const port_type port) { - listen(tcp::endpoint(tcp::v4(), port)); + listen(asio::ip::tcp::endpoint(asio::ip::tcp::v4(), port)); } -void TCPSocketServer::listen(const tcp::endpoint endpoint) { +void TCPSocketServer::listen(const asio::ip::tcp::endpoint endpoint) { doListen(acceptor, endpoint); - acceptor.set_option(tcp::no_delay(true)); + acceptor.set_option(asio::ip::tcp::no_delay(true)); } -tcp::endpoint TCPSocketServer::listenEndpoint() const { +asio::ip::tcp::endpoint TCPSocketServer::listenEndpoint() const { return acceptor.local_endpoint(); } @@ -63,7 +57,7 @@ void TCPSocketServer::acceptOnce() { doAcceptOnce(acceptor); } -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +#if defined(ASIO_HAS_LOCAL_SOCKETS) UnixSocketServer::UnixSocketServer(const ProtocolHandler* protocolHandler) : SocketServer(protocolHandler), acceptor(ios) { @@ -73,10 +67,10 @@ void UnixSocketServer::listen(const std::string& unixPath) { if (std::filesystem::status(unixPath).type() == std::filesystem::file_type::socket) std::filesystem::remove(unixPath); - doListen(acceptor, stream_protocol::endpoint(unixPath)); + doListen(acceptor, asio::local::stream_protocol::endpoint(unixPath)); } -stream_protocol::endpoint UnixSocketServer::listenEndpoint() const { +asio::local::stream_protocol::endpoint UnixSocketServer::listenEndpoint() const { return acceptor.local_endpoint(); } diff --git a/src/main.cpp b/src/main.cpp index fd7006fa..2c71cdcd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,7 +16,7 @@ void acceptWireProtocol( JsonWireMessageCodec wireCodec; WireProtocolHandler protocolHandler(wireCodec, cukeEngine); std::unique_ptr server; -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +#if defined(ASIO_HAS_LOCAL_SOCKETS) if (!unixPath.empty()) { UnixSocketServer* const unixServer = new UnixSocketServer(&protocolHandler); server.reset(unixServer); @@ -31,9 +31,7 @@ void acceptWireProtocol( { TCPSocketServer* const tcpServer = new TCPSocketServer(&protocolHandler); server.reset(tcpServer); - tcpServer->listen( - boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(host), port) - ); + tcpServer->listen(asio::ip::tcp::endpoint(asio::ip::address::from_string(host), port)); if (verbose) std::clog << "Listening on " << tcpServer->listenEndpoint() << std::endl; } @@ -60,7 +58,7 @@ int CUCUMBER_CPP_EXPORT main(int argc, char** argv) { ); cmd.add(portArg); -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +#if defined(ASIO_HAS_LOCAL_SOCKETS) TCLAP::ValueArg unixArg( "u", "unix", @@ -77,7 +75,7 @@ int CUCUMBER_CPP_EXPORT main(int argc, char** argv) { std::string unixPath; std::string listenHost = listenArg.getValue(); int port = portArg.getValue(); -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +#if defined(ASIO_HAS_LOCAL_SOCKETS) unixPath = unixArg.getValue(); #endif diff --git a/tests/integration/WireServerTest.cpp b/tests/integration/WireServerTest.cpp index 5827bcfc..8df02a03 100644 --- a/tests/integration/WireServerTest.cpp +++ b/tests/integration/WireServerTest.cpp @@ -12,10 +12,6 @@ #include using namespace cucumber::internal; -using namespace boost::asio::ip; -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) -using namespace boost::asio::local; -#endif using namespace testing; static const auto THREAD_TEST_TIMEOUT = std::chrono::milliseconds(4000); @@ -94,7 +90,7 @@ class TCPSocketServerTest : public SocketServerTest { TEST_F(TCPSocketServerTest, exitsOnFirstConnectionClosed) { // given - tcp::iostream client(server->listenEndpoint()); + asio::ip::tcp::iostream client(server->listenEndpoint()); ASSERT_THAT(client, IsConnected()); ASSERT_THAT(server->listenEndpoint().address().to_string(), std::string("0.0.0.0")); @@ -107,11 +103,11 @@ TEST_F(TCPSocketServerTest, exitsOnFirstConnectionClosed) { TEST_F(TCPSocketServerTest, moreThanOneClientCanConnect) { // given - tcp::iostream client1(server->listenEndpoint()); + asio::ip::tcp::iostream client1(server->listenEndpoint()); ASSERT_THAT(client1, IsConnected()); // when - tcp::iostream client2(server->listenEndpoint()); + asio::ip::tcp::iostream client2(server->listenEndpoint()); // then ASSERT_THAT(client2, IsConnected()); @@ -126,7 +122,7 @@ TEST_F(TCPSocketServerTest, receiveAndSendsSingleLineMassages) { } // given - tcp::iostream client(server->listenEndpoint()); + asio::ip::tcp::iostream client(server->listenEndpoint()); ASSERT_THAT(client, IsConnected()); // when @@ -145,7 +141,7 @@ class TCPSocketServerLocalhostTest : public SocketServerTest { SocketServer* createListeningServer() override { server.reset(new TCPSocketServer(&protocolHandler)); - server->listen(tcp::endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 0)); + server->listen(asio::ip::tcp::endpoint(asio::ip::address::from_string("127.0.0.1"), 0)); return server.get(); } @@ -156,7 +152,7 @@ class TCPSocketServerLocalhostTest : public SocketServerTest { TEST_F(TCPSocketServerLocalhostTest, listensOnLocalhost) { // given - tcp::iostream client(server->listenEndpoint()); + asio::ip::tcp::iostream client(server->listenEndpoint()); ASSERT_THAT(client, IsConnected()); ASSERT_THAT(server->listenEndpoint().address().to_string(), std::string("127.0.0.1")); @@ -167,7 +163,7 @@ TEST_F(TCPSocketServerLocalhostTest, listensOnLocalhost) { EXPECT_THAT(serverThread, EventuallyTerminates()); } -#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) +#if defined(ASIO_HAS_LOCAL_SOCKETS) class UnixSocketServerTest : public SocketServerTest { protected: std::unique_ptr server; @@ -204,14 +200,14 @@ class UnixSocketServerTest : public SocketServerTest { * created at startup and removed on shutdown. */ TEST_F(UnixSocketServerTest, fullLifecycle) { - stream_protocol::endpoint socketName = server->listenEndpoint(); + asio::local::stream_protocol::endpoint socketName = server->listenEndpoint(); EXPECT_CALL(protocolHandler, handle("X")).WillRepeatedly(Return("Y")); // socket created at startup ASSERT_TRUE(std::filesystem::exists(socketName.path())); // traffic flows - stream_protocol::iostream client(socketName); + asio::local::stream_protocol::iostream client(socketName); client << "X" << std::endl << std::flush; EXPECT_THAT(client, EventuallyReceives("Y"));