diff --git a/.gitmodules b/.gitmodules index 80a75427..7cb28b26 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "features/cucumber-tck"] path = features/cucumber-tck - url = git://github.com/cucumber/cucumber-tck.git + url = git://github.com/konserw/cucumber-tck.git diff --git a/CMakeLists.txt b/CMakeLists.txt index bc55f133..b60d2659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,6 @@ set(CUKE_DISABLE_E2E_TESTS OFF CACHE BOOL "Disable end-to-end tests") set(CUKE_ENABLE_EXAMPLES OFF CACHE BOOL "Enable the examples") set(GMOCK_DIR "" CACHE STRING "Google Mock framework sources path (otherwise downloaded)") set(GMOCK_VER "1.7.0" CACHE STRING "Google Mock framework version to be used") -set(VERBOSE OFF CACHE BOOL "Verbose output") set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) @@ -26,6 +25,24 @@ if(CMAKE_COMPILER_IS_GNUCXX) elseif(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX") # exclude M$ min/max macros #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /analyze") + add_definitions(-DNOMINMAX) # exclude M$ min/max macros + add_definitions(-D_SCL_SECURE_NO_WARNINGS) #turn off msvc warning + add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) #likewise + set(variables + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_MINSIZEREL + CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_RELWITHDEBINFO + ) + foreach(variable ${variables}) + if(${variable} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") + endif() + endforeach() endif() # @@ -48,8 +65,10 @@ endif() if(CUKE_USE_STATIC_BOOST) set(CUKE_STATIC_BOOST_LIBS ${CUKE_CORE_BOOST_LIBS}) # "An external test runner utility is required to link with dynamic library" (Boost User's Guide) - set(CUKE_DYNAMIC_BOOST_LIBS ${CUKE_TEST_BOOST_LIBS}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_TEST_DYN_LINK") + if(NOT CUKE_DISABLE_BOOST_TEST) + set(CUKE_DYNAMIC_BOOST_LIBS ${CUKE_TEST_BOOST_LIBS}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_TEST_DYN_LINK") + endif() if(NOT MSVC) find_package(Threads) @@ -62,6 +81,8 @@ endif() if(CUKE_STATIC_BOOST_LIBS) set(Boost_USE_STATIC_LIBS ON) + set(Boost_USE_STATIC_RUNTIME ON) + set(Boost_MULTITHREADED ON) find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS ${CUKE_STATIC_BOOST_LIBS}) endif() @@ -151,8 +172,7 @@ else() add_executable(e2e-steps EXCLUDE_FROM_ALL ${CUKE_DYNAMIC_CPP_STEPS}) target_link_libraries(e2e-steps ${CUKE_LIBRARIES}) - # TODO It does not escape paths - set(CUKE_COMPILE_DYNAMIC_CPP_STEPS "${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target e2e-steps") + set(CUKE_COMPILE_DYNAMIC_CPP_STEPS "cmake --build ${CMAKE_BINARY_DIR} --target e2e-steps") function(add_feature_target TARGET_NAME) add_custom_target(${TARGET_NAME} @@ -160,7 +180,7 @@ else() TEST_FEATURES_DIR=${CUKE_TEST_FEATURES_DIR} TMP_DIR=${CUKE_FEATURES_TMP} DYNAMIC_CPP_STEPS_SRC=${CUKE_DYNAMIC_CPP_STEPS} - DYNAMIC_CPP_STEPS_EXE=${CMAKE_BINARY_DIR}/e2e-steps + DYNAMIC_CPP_STEPS_EXE=${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/e2e-steps DYNAMIC_CPP_STEPS_OBJ=${CUKE_DYNAMIC_CPP_STEPS_OBJ} COMPILE_DYNAMIC_CPP_STEPS=${CUKE_COMPILE_DYNAMIC_CPP_STEPS} ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5} ${ARGV6} diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..302ac89c --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,59 @@ +version: "{branch}-ci-{build}" +image: Visual Studio 2015 + +platform: +- x86 +- x64 + +configuration: +- Debug +#- Release + +on_finish: +#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + +environment: + ruby_version: "200" + matrix: + - GENERATOR: '"Visual Studio 12 2013"' + BOOST_ROOT: 'C:\Libraries\boost' + BOOST_INCLUDEDIR: 'C:\Libraries\boost\boost' + BOOST_LIBRARYDIR: 'C:\Libraries\boost\lib32-msvc-12.0' + - GENERATOR: '"Visual Studio 12 2013"' + BOOST_ROOT: 'C:\Libraries\boost_1_58_0' + BOOST_INCLUDEDIR: 'C:\Libraries\boost_1_58_0\boost' + BOOST_LIBRARYDIR: 'C:\Libraries\boost_1_58_0\lib32-msvc-12.0' + - GENERATOR: '"Visual Studio 14 2015"' + BOOST_ROOT: 'C:\Libraries\boost_1_59_0' + BOOST_INCLUDEDIR: 'C:\Libraries\boost_1_59_0\boost' + BOOST_LIBRARYDIR: 'C:\Libraries\boost_1_59_0\lib32-msvc-14.0' + + +install: +- git submodule init +- git submodule update +- SET PATH=C:\Ruby%ruby_version%\bin;%PATH% +- ruby --version +- gem update --system --no-ri --no-rdoc -q > gem.log +- gem install bundler --no-document +- bundle install +- ps: .\fixCucumber.ps1 + +build_script: +- cmake -E make_directory build +- cmake -E chdir build cmake -G%GENERATOR% -DCUKE_DISABLE_BOOST_TEST=on -DCUKE_ENABLE_EXAMPLES=on -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_INCLUDEDIR="%BOOST_INCLUDEDIR%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" .. +- cmake --build build + +test_script: +- cmake --build build --target RUN_TESTS +- cmake --build build --target features + +notifications: +- provider: Email + to: +# - cukes-devs@googlegroups.com + - konserw@gmail.com + subject: "[cucumber-cpp] AppVeyor Build" + on_build_success: false + on_build_failure: true + on_build_status_changed: true diff --git a/cmake/modules/FindGMock.cmake b/cmake/modules/FindGMock.cmake index e7dcfb57..afa5ba34 100644 --- a/cmake/modules/FindGMock.cmake +++ b/cmake/modules/FindGMock.cmake @@ -173,12 +173,8 @@ add_library(libgmock IMPORTED STATIC GLOBAL) add_dependencies(libgmock gmock) ExternalProject_Get_Property(gmock source_dir binary_dir) -if(MSVC) - set(MS_DIR "/${CMAKE_BUILD_TYPE}") -endif() - -set(GTEST_LIB_DIR "${binary_dir}/gtest${MS_DIR}") -set(GMOCK_LIB_DIR "${binary_dir}${MS_DIR}") +set(GTEST_LIB_DIR "${binary_dir}/gtest/${CMAKE_CFG_INTDIR}") +set(GMOCK_LIB_DIR "${binary_dir}/${CMAKE_CFG_INTDIR}") set_target_properties(libgmock PROPERTIES "IMPORTED_LOCATION" "${GMOCK_LIB_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock.${Suffix}" diff --git a/features/cucumber-tck b/features/cucumber-tck index 11d6379b..8c228059 160000 --- a/features/cucumber-tck +++ b/features/cucumber-tck @@ -1 +1 @@ -Subproject commit 11d6379b9096f6aa9920e2861bd0530ca7c6302b +Subproject commit 8c2280590ab708686d84d8c0e32041d0fface582 diff --git a/features/step_definitions/cucumber_cpp_mappings.rb b/features/step_definitions/cucumber_cpp_mappings.rb index a9881396..170b3593 100644 --- a/features/step_definitions/cucumber_cpp_mappings.rb +++ b/features/step_definitions/cucumber_cpp_mappings.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'json' module CucumberCppMappings @@ -131,33 +133,47 @@ def write_mapping_calling_world_function(step_name) EOF end + def assert_returned_success + expect(@return).to be == true + end + + def assert_passing_feature + assert_no_partial_output("failed", @output.encode('UTF-8')) + expect(@return).to be == true + end + + def assert_failing_feature(message) + assert_partial_output(message, @output) + expect(@return).to be == false + end + def assert_passing_scenario - assert_partial_output("1 scenario (1 passed)", all_output) - assert_success true + assert_partial_output("1 scenario (1 passed)", @output) + expect(@return).to be == true end def assert_failing_scenario - assert_partial_output("1 scenario (1 failed)", all_output) - assert_success false + assert_partial_output("1 scenario (1 failed)", @output) + expect(@return).to be == false end def assert_pending_scenario - assert_partial_output("1 scenario (1 pending)", all_output) - assert_success true + assert_partial_output("1 scenario (1 pending)", @output) + expect(@return).to be == true end def assert_undefined_scenario - assert_partial_output("1 scenario (1 undefined)", all_output) - assert_success true + assert_partial_output("1 scenario (1 undefined)", @output) + expect(@return).to be == true end def assert_scenario_reported_as_failing(scenario_name) - assert_partial_output("# Scenario: #{scenario_name}", all_output) - assert_success false + assert_partial_output("# Scenario: #{scenario_name}", @output) + expect(@return).to be == false end def assert_scenario_not_reported_as_failing(scenario_name) - assert_no_partial_output("# Scenario: #{scenario_name}", all_output) + assert_no_partial_output("# Scenario: #{scenario_name}", @output) end def assert_suggested_step_definition_snippet(stepdef_keyword, stepdef_pattern, parameter_count = 0, doc_string = false, data_table = false) @@ -287,6 +303,7 @@ def nth_step_name n def run_feature_with_params(params) write_main_step_definitions_file + remove_step_definition_obj compile_step_definitions create_wire_file run_cucumber_cpp @@ -298,13 +315,13 @@ def write_main_step_definitions_file end def compile_step_definitions - remove_step_definition_obj compiler_output = %x[ #{COMPILE_STEP_DEFINITIONS_CMD} ] expect($?.success?).to be == true, "Compilation failed!\n#{compiler_output}" end def remove_step_definition_obj remove STEP_DEFINITIONS_OBJ + remove STEP_DEFINITIONS_EXE rescue Errno::ENOENT end @@ -320,7 +337,9 @@ def run_cucumber_cpp end def run_cucumber_test_feature(params) - run_simple "cucumber #{params} #{FEATURES_DIR}", false + cmd="cucumber #{params} #{FEATURES_DIR}" + @output = %x[ #{cmd} ] + @return = ($?.success?) end end diff --git a/features/support/hooks.rb b/features/support/hooks.rb index 182de0fb..70c18593 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -10,7 +10,7 @@ # for when there are no scenarios if @steps_out begin - Process.kill :SIGTERM, @steps_out.pid + Process.kill "KILL", @steps_out.pid #windows accepts only KILL signal - do not change please Process.wait @steps_out.pid rescue Errno::ESRCH # exited already rescue Errno::ECHILD # killed before wait call diff --git a/fixCucumber.ps1 b/fixCucumber.ps1 new file mode 100644 index 00000000..2b600410 --- /dev/null +++ b/fixCucumber.ps1 @@ -0,0 +1,9 @@ +If ($env:ruby_version -match "200") { + $path = "C:\Ruby200\lib\ruby\gems\2.0.0\gems\cucumber-2.0.0\lib\cucumber\formatter\ansicolor.rb" +} Else { + $path = "C:\Ruby193\lib\ruby\gems\1.9.1\gems\cucumber-2.0.0\lib\cucumber\formatter\ansicolor.rb" +} + +(Get-Content $path) -replace '\ST\DERR.puts %', '#nope' | Set-Content $path +(Get-Content $path) -replace ' Cucumber::', '#nope' | Set-Content $path +(Get-Content $path) -replace '^Cucumber::', '#nope' | Set-Content $path