diff --git a/.travis.yml b/.travis.yml index 096dcf55..be89cf09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,24 @@ language: cpp +os: + - osx + - linux sudo: required dist: trusty compiler: - clang - gcc env: - matrix: - - GMOCK_VER=1.7.0 - - GMOCK_PATH=/usr/src/gmock #1.6.0 from ubuntu trusty repo - +# - GMOCK_VER=1.6.0 + - GMOCK_VER=1.7.0 + - GMOCK_PATH=/usr/src/gmock #1.6.0 from ubuntu trusty repo +matrix: + exclude: +# - os: linux +# env: GMOCK_VER=1.6.0 + - os: osx + env: GMOCK_PATH=/usr/src/gmock + - os: osx + compiler: gcc #does anyone on osx use it? addons: apt: packages: @@ -17,6 +27,7 @@ addons: - libboost-regex-dev - libboost-date-time-dev - libboost-test-dev + - libboost-program-options-dev - google-mock script: ./travis.sh @@ -24,3 +35,7 @@ script: ./travis.sh notifications: email: - cukes-devs@googlegroups.com + +branches: + only: + - master diff --git a/CMakeLists.txt b/CMakeLists.txt index 28e03fc9..77851950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ else() set(BOOST_MIN_VERSION "1.40") endif() -set(CUKE_CORE_BOOST_LIBS thread system regex date_time) +set(CUKE_CORE_BOOST_LIBS thread system regex date_time program_options) if(NOT CUKE_DISABLE_BOOST_TEST) set(CUKE_TEST_BOOST_LIBS unit_test_framework) endif() @@ -73,7 +73,7 @@ endif() if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) - set(CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) + set(CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) endif() # diff --git a/Gemfile b/Gemfile index 0357afa7..19248b76 100644 --- a/Gemfile +++ b/Gemfile @@ -4,5 +4,6 @@ group :test do gem 'cucumber', "=1.3.20" gem 'aruba', "=0.6.1" gem 'rspec', "=2.14.1" + gem 'os' end diff --git a/README.md b/README.md index a82d9b46..bc2b6957 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ with [CPP]. It relies on a few libraries: -* [Boost](http://www.boost.org/) 1.40 or later. - Required libraries: *thread*, *system*, *regex*, and *date_time*. +* [Boost](http://www.boost.org/) 1.40 or later (1.51 for MSVC11). + Required libraries: *thread*, *system*, *regex*, *program_options* and *date_time*. 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. diff --git a/features/step_definitions/cucumber_cpp_mappings.rb b/features/step_definitions/cucumber_cpp_mappings.rb index 9dee4c36..3398d971 100644 --- a/features/step_definitions/cucumber_cpp_mappings.rb +++ b/features/step_definitions/cucumber_cpp_mappings.rb @@ -1,4 +1,5 @@ require 'json' +require 'os' module CucumberCppMappings @@ -292,8 +293,11 @@ def run_feature_with_params(params) create_wire_file run_cucumber_cpp run_cucumber_test_feature params - Process.kill(:SIGTERM, @steps_out.pid) # for when there are no scenarios - Process.wait @steps_out.pid + begin + Process.kill(:SIGTERM, @steps_out.pid) + Process.wait @steps_out.pid + rescue Errno::ESRCH + end end def write_main_step_definitions_file @@ -301,6 +305,9 @@ def write_main_step_definitions_file end def compile_step_definitions + if OS.mac? + File.delete("./CMakeFiles/functional-steps.dir/tmp/test_features/step_definitions/cpp_steps.cpp.o") + end compiler_output = %x[ #{COMPILE_STEP_DEFINITIONS_CMD} ] expect($?.success?).to be_true, "Compilation failed!\n#{compiler_output}" end @@ -313,7 +320,7 @@ def create_wire_file end def run_cucumber_cpp - @steps_out = IO.popen STEP_DEFINITIONS_EXE + @steps_out = IO.popen STEP_DEFINITIONS_EXE end def run_cucumber_test_feature(params) diff --git a/src/main.cpp b/src/main.cpp index 5288980e..348d5216 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,32 +2,57 @@ #include #include #include +#include +using boost::program_options::value; namespace { -void acceptWireProtocol(int port) { +void acceptWireProtocol(int port, bool verbose = false) { using namespace ::cucumber::internal; CukeEngineImpl cukeEngine; JsonSpiritWireMessageCodec wireCodec; WireProtocolHandler protocolHandler(&wireCodec, &cukeEngine); SocketServer server(&protocolHandler); server.listen(port); + if (verbose) + std::cerr << "Listening on port " << port << std::endl; server.acceptOnce(); } } int main(int argc, char **argv) { + bool verbose = false; + + boost::program_options::options_description optionDescription("Allowed options"); + optionDescription.add_options() + ("help,h", "help for cucumber-cpp") + ("verbose,v", "verbose output") + ("port,p", value(), "listening port of wireserver") + ; + 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::cout << optionDescription << std::endl; + return 0; + } + + if (optionVariableMap.count("verbose")) { + verbose = true; + } + + int port = 3902; + if (optionVariableMap.count("port")) { + port = optionVariableMap["port"].as(); + } + try { - int port = 3902; - if (argc > 1) { - std::string firstArg(argv[1]); - port = ::cucumber::internal::fromString(firstArg); - } - acceptWireProtocol(port); + acceptWireProtocol(port, verbose); } catch (std::exception &e) { std::cerr << e.what() << std::endl; - exit(1); + return 1; } return 0; }