Skip to content

Commit

Permalink
Merge cucumber#189 'Fix build'
Browse files Browse the repository at this point in the history
This is group-merge which consist actualy of following fixes:
* Remove -werror compiler flag to fix failing build with clang ([cucumber#184](cucumber#184) Kamil Strzempowicz)
* Add missing virtual destructor in base class SocketServer used by TCPSocketServer and UnixSocketServer ([cucumber#183](cucumber#183) Matthieu Longo)
* Fix breaking changes in API of boost-1.66.0 ([cucumber#180](cucumber#180)  Matthieu Longo)
* Fix conflicting "using std" declaration with "using boost::thread" ([cucumber#181](cucumber#181)  Matthieu Longo)
* Fixing Visual Studio 2013 error: no appropriate default constructor available ([cucumber#188](cucumber#188) Antoine Allard)
  • Loading branch information
konserw committed Mar 30, 2018
2 parents 5750774 + 5162038 commit dd83907
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO

### Fixed

* Remove -werror compiler flag to fix failing build with clang ([#184](https://github.com/cucumber/cucumber-cpp/pull/184) Kamil Strzempowicz)
* Add missing virtual destructor in base class SocketServer used by TCPSocketServer and UnixSocketServer ([#183](https://github.com/cucumber/cucumber-cpp/pull/183) Matthieu Longo)
* Fix breaking changes in API of boost-1.66.0 ([#180](https://github.com/cucumber/cucumber-cpp/pull/180) Matthieu Longo)
* Fix conflicting "using std" declaration with "using boost::thread" ([#181](https://github.com/cucumber/cucumber-cpp/pull/181) Matthieu Longo)
* Fixing Visual Studio 2013 error: no appropriate default constructor available ([#188](https://github.com/cucumber/cucumber-cpp/pull/188) Antoine Allard)
* Fix issue #81 by intercepting messages from BOOST_*_MESSAGE macros ([#164](https://github.com/cucumber/cucumber-cpp/pull/164) Kamil Strzempowicz)
* Allow running all GTest cases without filter separation ([#144](https://github.com/cucumber/cucumber-cpp/pull/144) Giel van Schijndel)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
#

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -Wextra -Werror ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -Wextra ${CMAKE_CXX_FLAGS}")
# TODO: A better fix should handle ld's --as-needed flag
if(UNIX AND NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker '--no-as-needed'")
Expand Down
11 changes: 10 additions & 1 deletion include/cucumber-cpp/internal/connectors/wire/WireServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SocketServer {
* Constructor for DI
*/
SocketServer(const ProtocolHandler *protocolHandler);
virtual ~SocketServer() {}

/**
* Accept one connection
Expand All @@ -29,11 +30,19 @@ class SocketServer {
const ProtocolHandler *protocolHandler;
boost::asio::io_service ios;

#if BOOST_VERSION <= 106500
template <typename Protocol, typename Service>
void doListen(boost::asio::basic_socket_acceptor<Protocol, Service>& acceptor,
const typename Protocol::endpoint& endpoint);
const typename Protocol::endpoint& endpoint);
template <typename Protocol, typename Service>
void doAcceptOnce(boost::asio::basic_socket_acceptor<Protocol, Service>& acceptor);
#else
template <typename Protocol>
void doListen(boost::asio::basic_socket_acceptor<Protocol>& acceptor,
const typename Protocol::endpoint& endpoint);
template <typename Protocol>
void doAcceptOnce(boost::asio::basic_socket_acceptor<Protocol>& acceptor);
#endif
void processStream(std::iostream &stream);
};

Expand Down
13 changes: 12 additions & 1 deletion src/connectors/wire/WireServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ SocketServer::SocketServer(const ProtocolHandler *protocolHandler) :
ios() {
}

#if BOOST_VERSION <= 106500
template <typename Protocol, typename Service>
void SocketServer::doListen(basic_socket_acceptor<Protocol, Service>& acceptor,
const typename Protocol::endpoint& endpoint) {
const typename Protocol::endpoint& endpoint) {
#else
template <typename Protocol>
void SocketServer::doListen(basic_socket_acceptor<Protocol>& 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());
Expand All @@ -26,8 +32,13 @@ void SocketServer::doListen(basic_socket_acceptor<Protocol, Service>& acceptor,
acceptor.listen(1);
}

#if BOOST_VERSION <= 106500
template <typename Protocol, typename Service>
void SocketServer::doAcceptOnce(basic_socket_acceptor<Protocol, Service>& acceptor) {
#else
template <typename Protocol>
void SocketServer::doAcceptOnce(basic_socket_acceptor<Protocol>& acceptor) {
#endif
typename Protocol::iostream stream;
acceptor.accept(*stream.rdbuf());
processStream(stream);
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/WireServerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ using namespace boost::asio::ip;
#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
using namespace boost::asio::local;
#endif
using namespace std;
using namespace testing;
using boost::bind;
using boost::thread;
namespace fs = boost::filesystem;

static const time_duration THREAD_TEST_TIMEOUT = milliseconds(4000);

MATCHER(IsConnected, string(negation ? "is not" : "is") +
" connected") { return arg.good(); }
MATCHER(IsConnected, std::string(negation ? "is not" : "is") + " connected") {
return arg.good();
}

MATCHER(HasTerminated, "") {
return !arg.joinable();
Expand Down Expand Up @@ -55,7 +55,7 @@ MATCHER_P(EventuallyReceives, value, "") {

class MockProtocolHandler : public ProtocolHandler {
public:
MOCK_CONST_METHOD1(handle, string(const string &request));
MOCK_CONST_METHOD1(handle, std::string(const std::string& request));
};

class SocketServerTest : public Test {
Expand Down Expand Up @@ -134,8 +134,8 @@ TEST_F(TCPSocketServerTest, receiveAndSendsSingleLineMassages) {
ASSERT_THAT(client, IsConnected());

// when
client << "1" << flush << "2" << endl << flush;
client << "3" << endl << "4" << endl << flush;
client << "1" << std::flush << "2" << std::endl << std::flush;
client << "3" << std::endl << "4" << std::endl << std::flush;

// then
EXPECT_THAT(client, EventuallyReceives("A"));
Expand Down Expand Up @@ -204,7 +204,7 @@ TEST_F(UnixSocketServerTest, fullLifecycle) {

// traffic flows
stream_protocol::iostream client(socketName);
client << "X" << endl << flush;
client << "X" << std::endl << std::flush;
EXPECT_THAT(client, EventuallyReceives("Y"));

// client disconnection terminates server
Expand Down

0 comments on commit dd83907

Please sign in to comment.