diff --git a/.gitignore b/.gitignore index 35c39c33..8d79a2be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +# vim swap files +*.swp # Qt Creator CMakeLists.txt.user diff --git a/.gitmodules b/.gitmodules index 80a75427..699b39f3 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 = https://github.com/konserw/cucumber-tck.git diff --git a/.travis.yml b/.travis.yml index 096dcf55..90d7e3e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,3 +24,7 @@ script: ./travis.sh notifications: email: - cukes-devs@googlegroups.com + +branches: + only: + - master diff --git a/CMakeLists.txt b/CMakeLists.txt index 28e03fc9..0cd85ce5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,27 @@ if(CMAKE_COMPILER_IS_GNUCXX) # TODO: A better fix should handle ld's --as-needed flag set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker '--no-as-needed'") 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 + # link_directories("C:/Libraries/boost/lib32-msvc-12.0") + # add_definitions(-D_WIN32_WINNT=0x0600) #windows vista + 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() # @@ -47,22 +66,28 @@ if(NOT CUKE_DISABLE_BOOST_TEST) endif() if(CUKE_USE_STATIC_BOOST) + message(STATUS "Using 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) set(CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) endif() else() + message(STATUS "Using DYNAMIC BOOST") set(CUKE_DYNAMIC_BOOST_LIBS ${CUKE_CORE_BOOST_LIBS} ${CUKE_TEST_BOOST_LIBS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_ALL_DYN_LINK") 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() @@ -148,16 +173,18 @@ if(NOT CUKE_DISABLE_FUNCTIONAL) add_executable(functional-steps EXCLUDE_FROM_ALL ${CUKE_DYNAMIC_CPP_STEPS}) target_link_libraries(functional-steps ${CUKE_LIBRARIES}) - # TODO It does not escape paths - set(CUKE_COMPILE_DYNAMIC_CPP_STEPS "${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target functional-steps") - + set(CUKE_COMPILE_DYNAMIC_CPP_STEPS "cmake --build ${CMAKE_BINARY_DIR} --target functional-steps") + if(VERBOSE) + message(STATUS, "compile dnamic steps command: ${CUKE_COMPILE_DYNAMIC_CPP_STEPS}") + message(STATUS, "cucumber: ${CUCUMBER_RUBY}") + endif() function(add_feature_target TARGET_NAME) add_custom_target(${TARGET_NAME} COMMAND ${CUCUMBER_RUBY} 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}/functional-steps + DYNAMIC_CPP_STEPS_EXE="${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/functional-steps" COMPILE_DYNAMIC_CPP_STEPS=${CUKE_COMPILE_DYNAMIC_CPP_STEPS} ${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5} ${ARGV6} ${CUKE_FEATURES_DIR} diff --git a/Gemfile b/Gemfile index 0357afa7..6a6a0374 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source 'https://rubygems.org' group :test do - gem 'cucumber', "=1.3.20" - gem 'aruba', "=0.6.1" - gem 'rspec', "=2.14.1" + gem 'cucumber', "=2.0.0" + gem 'aruba', "=0.8.0" + gem 'rspec', "=3.4.0" end diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..28af37a3 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,53 @@ +version: "{branch}-ci-{build}" +os: +- Visual Studio 2013 + +platform: +- Win32 + +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: + matrix: + - BOOST_ROOT: C:\Libraries\boost + BOOST_INCLUDEDIR: C:\Libraries\boost\boost + BOOST_LIBRARYDIR: C:\Libraries\boost\lib32-msvc-12.0 + ruby_version: "193" + - 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 + ruby_version: "200" + +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 gem-shut-the-fuck-up +- gem install bundler --no-document +- bundle install +- ps: .\fixCucumber.ps1 + +build_script: +- cmake -E make_directory build +- cmake -E chdir build cmake -DAPPVEYOR=on -DVERBOSE=on -DCUKE_ENABLE_EXAMPLES=on -DCUKE_DISABLE_BOOST_TEST=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 + subject: "[cucumber-cpp] AppVeyor Build {version}" + 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..a24589d8 100644 --- a/cmake/modules/FindGMock.cmake +++ b/cmake/modules/FindGMock.cmake @@ -174,9 +174,8 @@ add_dependencies(libgmock gmock) ExternalProject_Get_Property(gmock source_dir binary_dir) if(MSVC) - set(MS_DIR "/${CMAKE_BUILD_TYPE}") + set(MS_DIR "/${CMAKE_CFG_INTDIR}") endif() - set(GTEST_LIB_DIR "${binary_dir}/gtest${MS_DIR}") set(GMOCK_LIB_DIR "${binary_dir}${MS_DIR}") @@ -219,4 +218,3 @@ if(GTEST_FOUND) Message(STATUS "GTest libs: ${GTEST_BOTH_LIBRARIES}") endif() endif() - diff --git a/features/cucumber-tck b/features/cucumber-tck index 7ea91477..8c228059 160000 --- a/features/cucumber-tck +++ b/features/cucumber-tck @@ -1 +1 @@ -Subproject commit 7ea91477edd14180ded92f7699d09689227644cd +Subproject commit 8c2280590ab708686d84d8c0e32041d0fface582 diff --git a/features/step_definitions/cucumber_cpp_mappings.rb b/features/step_definitions/cucumber_cpp_mappings.rb index 9dee4c36..f83709e8 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) @@ -172,36 +188,34 @@ def assert_executed_scenarios *scenario_offsets end def assert_world_variable_held_value_at_time(value, time) - check_exact_file_content "#{WORLD_VARIABLE_LOG_FILE}.#{time}", value + expect(File.read("#{WORLD_VARIABLE_LOG_FILE}.#{time}")).to match value end def assert_world_function_called - check_file_presence [WORLD_FUNCTION_LOG_FILE], true + expect(File.file?(WORLD_FUNCTION_LOG_FILE)).to be true end def assert_cycle_sequence *args expected_string = args.join CYCLE_SEQUENCE_SEPARATOR - check_file_content(CYCLE_LOG_FILE, expected_string, true) + expect(File.read(CYCLE_LOG_FILE)).to match expected_string end def assert_cycle_sequence_excluding *args args.each do |unexpected_string| - check_file_content(CYCLE_LOG_FILE, unexpected_string, false) + expect(File.read(CYCLE_LOG_FILE)).not_to match unexpected_string end end def assert_complete_cycle_sequence *args expected_string = "#{CYCLE_SEQUENCE_SEPARATOR}#{args.join(CYCLE_SEQUENCE_SEPARATOR)}" - check_exact_file_content(CYCLE_LOG_FILE, expected_string) + expect(File.read(CYCLE_LOG_FILE)).to match expected_string end def assert_data_table_equals_json(json) - prep_for_fs_check do - log_file_contents = IO.read(DATA_TABLE_LOG_FILE) - actual_array = JSON.parse(log_file_contents) - expected_array = JSON.parse(json) - actual_array.should == expected_array - end + log_file_contents = File.read(DATA_TABLE_LOG_FILE) + actual_array = JSON.parse(log_file_contents) + expected_array = JSON.parse(json) + expect(actual_array).to be == expected_array end def run_feature @@ -292,8 +306,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(9, @steps_out.pid) + Process.wait @steps_out.pid + rescue Errno::ESRCH + end end def write_main_step_definitions_file @@ -302,7 +319,7 @@ def write_main_step_definitions_file def compile_step_definitions compiler_output = %x[ #{COMPILE_STEP_DEFINITIONS_CMD} ] - expect($?.success?).to be_true, "Compilation failed!\n#{compiler_output}" + expect($?.success?).to be == true, "Compilation failed!\n#{compiler_output}" end def create_wire_file @@ -317,7 +334,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/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 diff --git a/src/drivers/GTestDriver.cpp b/src/drivers/GTestDriver.cpp index 072e94be..8a19b218 100644 --- a/src/drivers/GTestDriver.cpp +++ b/src/drivers/GTestDriver.cpp @@ -1,6 +1,6 @@ #include -#include +#include "gtest/gtest.h" namespace cucumber { namespace internal { diff --git a/travis.sh b/travis.sh index 4c30f28e..5e079d24 100755 --- a/travis.sh +++ b/travis.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e #break script on non-zero exitcode from any command +gem install gem-shut-the-fuck-up gem install bundler cmake -E make_directory build