diff --git a/.github/workflows/qt5.yaml b/.github/workflows/qt5.yaml index 15119e44..d613d58b 100644 --- a/.github/workflows/qt5.yaml +++ b/.github/workflows/qt5.yaml @@ -80,6 +80,6 @@ jobs: ; do "${TEST}" 2> /dev/null & sleep 1 - (cd examples/CalcQt; cucumber) + (cd examples/CalcQt; cucumber --strict) wait % done diff --git a/.github/workflows/run-all.yaml b/.github/workflows/run-all.yaml index 5dda7406..03b71966 100644 --- a/.github/workflows/run-all.yaml +++ b/.github/workflows/run-all.yaml @@ -16,7 +16,20 @@ concurrency: jobs: build-linux: - runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + include: + - cucumber-version: '7.1' + os: ubuntu-22.04 + # Cucumber-Ruby 10 needs Ruby 3.1 or later, Ubuntu 22.04 provides Ruby 3.0 + - cucumber-version: '10' + os: ubuntu-24.04 + + runs-on: ${{ matrix.os }} + + env: + CUCUMBER_VERSION: ${{ matrix.cucumber-version }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -46,7 +59,7 @@ jobs: - name: install ruby tools run: | sudo gem install bundler - sudo bundle install + sudo env CUCUMBER_VERSION="${CUCUMBER_VERSION}" bundle install - name: install gtest run: | diff --git a/Gemfile b/Gemfile index d53a1beb..92814591 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,18 @@ source 'https://rubygems.org' -group :test do - gem 'cucumber', "=7.1.0" - gem 'cucumber-wire', "=6.2.1" +# Select the Cucumber-Ruby version with CUCUMBER_VERSION, for example +# `export CUCUMBER_VERSION=10` before `bundle install`. Keep it set for `bundle exec`, +# otherwise Bundler switches back to the default. Cucumber-Ruby 10 needs Ruby 3.1 or later. +cucumber_versions = { + '7.1' => { cucumber: '7.1.0', wire: '6.2.1' }, + '10' => { cucumber: '10.2.0', wire: '8.0.0' }, +} +cucumber_version = ENV.fetch('CUCUMBER_VERSION', '7.1') +versions = cucumber_versions.fetch(cucumber_version) do + raise "Unsupported CUCUMBER_VERSION '#{cucumber_version}', use one of: #{cucumber_versions.keys.join(', ')}" end +group :test do + gem 'cucumber', "=#{versions[:cucumber]}" + gem 'cucumber-wire', "=#{versions[:wire]}" +end diff --git a/README.md b/README.md index f6e86813..f68feee7 100644 --- a/README.md +++ b/README.md @@ -31,15 +31,15 @@ It relies on a few libraries: * [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. +See the [CI scripts](.github/workflows/run-all.yaml) for details about dependency installation. Cucumber-Cpp uses the wire protocol at the moment, so you will need -Cucumber-Ruby installed and available on the path. It is also needed -to run the functional test suite. +Cucumber-Ruby and its cucumber-wire plugin installed and available on +the path. They are also needed to run the functional test suite. -Please mind that Cucumber-Cpp is not compatible with Cucumber-Ruby 3.x -due to a [bug in its wire protocol](https://github.com/cucumber/cucumber-ruby/issues/1183) -implementation. +Cucumber-Cpp is tested with Cucumber-Ruby 7.1 and 10. Later versions +are not supported yet, because there is no cucumber-wire release for +them. Cucumber-Ruby 10 needs Ruby 3.1 or later. To install the Ruby prerequisites: @@ -48,10 +48,14 @@ gem install bundler // For windows: gem install bundle bundle install ``` +This installs Cucumber-Ruby 7.1. To use Cucumber-Ruby 10 instead, set +the environment variable `CUCUMBER_VERSION=10` before running +`bundle install` and keep it set when running `bundle exec`. + ### Windows vs. Linux To get an inspiration on how to set up the dependencies on your specific system (Windows or Linux), you may want to have a look at the -workflow files [for Windows](.github/workflows/windows-build.yml) and [for Linux](.github/workflows/linux-build.yml). +workflow files [for Windows](.github/workflows/windows-build.yaml) and [for Linux](.github/workflows/linux-build.yaml). ## Build @@ -92,7 +96,8 @@ Running the Calc example on Windows (NMake): ``` start build\examples\Calc\BoostCalculatorSteps.exe -cucumber examples\Calc +cd examples\Calc +cucumber ``` ## The way it works @@ -131,8 +136,14 @@ host: localhost port: 3902 ``` +Cucumber-Ruby 8 and later ignore the *cucumber.wire* file unless the wire protocol plugin is loaded. Create a *wire.rb* file in the *features/support* folder with the following content (Cucumber-Ruby 7.1 works with it as well): + +``` +require 'cucumber/wire' +``` + Create your first feature (an example is available [here](examples/Calc/features/addition.feature)). Then create your step definition runner (an example is available [here](examples/Calc/features/step_definitions/BoostCalculatorSteps.cpp)). In order to compile the step definition runner, make sure to add [cucumber include directory](include/cucumber-cpp) to the include path and link with *libcucumber-cpp.a* and additional testing libraries (boost unit test). -Run the step definition runner in the background and then cucumber, like in the Calc example in the previous section. The step definition runner should exit after the feature is run and cucumber exits. +Run the step definition runner in the background and then cucumber, like in the Calc example in the previous section. Start cucumber in the folder that contains the *features* folder, otherwise it does not find the *cucumber.wire* file. The step definition runner should exit after the feature is run and cucumber exits. diff --git a/examples/Calc/features/support/wire.rb b/examples/Calc/features/support/wire.rb new file mode 100644 index 00000000..0e1eb3fd --- /dev/null +++ b/examples/Calc/features/support/wire.rb @@ -0,0 +1,2 @@ +# Cucumber-Ruby 8 and later only load the wire protocol plugin on request +require 'cucumber/wire' diff --git a/examples/CalcQt/features/support/wire.rb b/examples/CalcQt/features/support/wire.rb new file mode 100644 index 00000000..0e1eb3fd --- /dev/null +++ b/examples/CalcQt/features/support/wire.rb @@ -0,0 +1,2 @@ +# Cucumber-Ruby 8 and later only load the wire protocol plugin on request +require 'cucumber/wire' diff --git a/examples/FeatureShowcase/features/support/wire.rb b/examples/FeatureShowcase/features/support/wire.rb new file mode 100644 index 00000000..0e1eb3fd --- /dev/null +++ b/examples/FeatureShowcase/features/support/wire.rb @@ -0,0 +1,2 @@ +# Cucumber-Ruby 8 and later only load the wire protocol plugin on request +require 'cucumber/wire' diff --git a/run-linux.sh b/run-linux.sh index 62518385..a23bb2fd 100755 --- a/run-linux.sh +++ b/run-linux.sh @@ -36,7 +36,7 @@ for TEST in \ ; do "${TEST}" > /dev/null & sleep 1 - (cd examples/Calc; cucumber) + (cd examples/Calc; cucumber --strict) wait % done @@ -51,7 +51,7 @@ for TEST in \ ; do "${TEST}" 2> /dev/null & sleep 1 - (cd examples/CalcQt; cucumber) + (cd examples/CalcQt; cucumber --strict) wait % done @@ -63,7 +63,7 @@ SOCK=`pwd`/cucumber.wire.sock TEST=build/examples/FeatureShowcase/FeatureShowcaseSteps echo "unix: ${SOCK}" > examples/FeatureShowcase/features/step_definitions/cucumber.wire "${TEST}" --unix "${SOCK}" > /dev/null & -(cd examples/FeatureShowcase; cucumber) +(cd examples/FeatureShowcase; cucumber --strict) wait % mkdir -p coverage