diff --git a/.rspec b/.rspec index 7c6c4a8dc..8521aa4ae 100644 --- a/.rspec +++ b/.rspec @@ -1,4 +1,3 @@ --color ---format Fuubar --order random --warnings diff --git a/.travis.yml b/.travis.yml index 8c25cd7c4..24fa02a4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,18 +31,18 @@ jobs: os: linux - rvm: jruby os: linux - - rvm: jruby-9.2.7.0 + - rvm: jruby-9.2.6.0 os: linux - - rvm: jruby-9.2.7.0 + - rvm: jruby-9.2.6.0 os: osx + env: JAVA_OPTS="--add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/javax.crypto=ALL-UNNAMED --add-opens java.base/java.security.cert=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --illegal-access=warn" + script: bundle exec rake test:rspec - stage: lint script: bundle exec rake lint rvm: 2.6.3 os: linux allow_failures: - rvm: ruby-head - - rvm: jruby - - rvm: jruby-9.2.7.0 fast_finish: true branches: @@ -54,20 +54,13 @@ branches: # slack: cucumberbdd:oQFVhzsx4R94KWmjlejAJYnM env: global: - - secure: l8uznA5K4K9mZ1krmP3lTMD8WcJ32qGxFOR3jubKHcOBSLB4xSzU2aIqjyJdO+rLzebkwamhJc8pGSIWOUDQYvFiX7splK+uEkbBJ5huAhXtLF4Qgl86bCWbEXYzN7rvn0DQfpJAovyFMNRMnfo70XhwqWzFsaYa7Z0YbqYsJE4= - # Travis by default also have "-Dcext.enabled=false" set in - # JRUBY_OPTS, but JRuby 9 does not support C extensions at all - # so it issues warning that will mess up the sterr checks. - - JRUBY_OPTS="--dev --debug" - # Somehow a "ASCII-8BIT to UTF-8 conversion error" appears for - # JRuby 9 - - LC_ALL=en_US.UTF-8 - - LANG=en_US.UTF-8 - - LANGUAGE=en_US.UTF-8 - -cache: apt - -addons: - apt: - packages: - - zsh + - secure: l8uznA5K4K9mZ1krmP3lTMD8WcJ32qGxFOR3jubKHcOBSLB4xSzU2aIqjyJdO+rLzebkwamhJc8pGSIWOUDQYvFiX7splK+uEkbBJ5huAhXtLF4Qgl86bCWbEXYzN7rvn0DQfpJAovyFMNRMnfo70XhwqWzFsaYa7Z0YbqYsJE4= + # Travis by default also have "-Dcext.enabled=false" set in + # JRUBY_OPTS, but JRuby 9 does not support C extensions at all + # so it issues warning that will mess up the stderr checks. + - JRUBY_OPTS="--dev --debug" + # Somehow a "ASCII-8BIT to UTF-8 conversion error" appears for + # JRuby 9 + - LC_ALL=en_US.UTF-8 + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 diff --git a/aruba.gemspec b/aruba.gemspec index c77b86ca8..c887d0c0c 100644 --- a/aruba.gemspec +++ b/aruba.gemspec @@ -19,7 +19,6 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'rspec-expectations', '~> 3.4' spec.add_runtime_dependency 'thor', '~> 0.19' - spec.add_development_dependency 'fuubar', '~> 2.3' spec.add_development_dependency 'json', '~> 2.1' spec.add_development_dependency 'license_finder', '~> 5.3' spec.add_development_dependency 'minitest', '~> 5.10' diff --git a/cucumber.yml b/cucumber.yml index 0d6d54a18..e1a24d4f3 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -1,17 +1,6 @@ <% -$LOAD_PATH << ::File.expand_path('../lib', __FILE__) -require 'aruba/version' -require 'ffi' - -java_version = (RUBY_DESCRIPTION.match(/.*?on.*?(1\.[\d]\..*? )/))[1] if defined?(JRUBY_VERSION) - -std_opts = "--format pretty --color --exclude features/fixtures --require features --tags ~@unsupported-on" -java_default_opts = "--tags ~@wip-jruby-java-1.6" if defined?(JRUBY_VERSION) && (java_version < '1.7.0') -java_wip_opts = "--tags @wip-jruby-java-1.6:3" if defined?(JRUBY_VERSION) && (java_version < '1.7.0') - -ignore_opts = [] -ignore_opts << '--tags ~@ignore' -ignore_opts = ignore_opts.join(' ') +std_opts = "--format pretty --color --exclude features/fixtures --require features --tags ~@unsupported-on" +ignore_opts = '--tags ~@ignore' %> -default: <%= std_opts %> --tags ~@wip <%= java_default_opts %> <%= ignore_opts %> -wip: <%= std_opts %> --wip --tags @wip:3 <%= java_wip_opts %> <%= ignore_opts %> +default: <%= std_opts %> --tags ~@wip <%= ignore_opts %> +wip: <%= std_opts %> --wip --tags @wip:3 <%= ignore_opts %> diff --git a/features/03_testing_frameworks/cucumber/overview.feature b/features/03_testing_frameworks/cucumber/overview.feature deleted file mode 100644 index 833dcfbac..000000000 --- a/features/03_testing_frameworks/cucumber/overview.feature +++ /dev/null @@ -1,25 +0,0 @@ -Feature: Overview of steps - - Given you're a system administrator - Who would like to use `aruba` - But didn't know which steps are available - - Scenario: Use cucumber output formatter - Given I use a fixture named "cli-app" - And a file named "features/run.feature" with: - """ - Feature: Run it - Scenario: Run command - Given a directory named "features" - And a file named "features/support/env.rb" with: - \"\"\" - require 'aruba/cucumber' - \"\"\" - When I run `cucumber --format stepdefs` - Then the output should contain: - \"\"\" - NOT MATCHED BY ANY STEPS - \"\"\" - """ - When I run `cucumber` - Then the features should all pass diff --git a/features/03_testing_frameworks/cucumber/steps/command/run_command_in_process.feature b/features/03_testing_frameworks/cucumber/steps/command/run_command_in_process.feature index 3fbfb82d0..ecb5e085b 100644 --- a/features/03_testing_frameworks/cucumber/steps/command/run_command_in_process.feature +++ b/features/03_testing_frameworks/cucumber/steps/command/run_command_in_process.feature @@ -349,8 +349,7 @@ Feature: Run commands in ruby process type some letters on keyboard - can only appear later, but this point is never reached, because ruby is blocked. - Given the default aruba exit timeout is 3 seconds - And a file named "lib/cli/app/runner.rb" with: + Given a file named "lib/cli/app/runner.rb" with: """ module Cli module App diff --git a/features/03_testing_frameworks/cucumber/steps/command/run_command_interactively.feature b/features/03_testing_frameworks/cucumber/steps/command/run_command_interactively.feature index 39bc01056..3e6530942 100644 --- a/features/03_testing_frameworks/cucumber/steps/command/run_command_interactively.feature +++ b/features/03_testing_frameworks/cucumber/steps/command/run_command_interactively.feature @@ -7,7 +7,6 @@ Feature: Running an interactive command Background: Given I use a fixture named "cli-app" - @wip-jruby-java-1.6 Scenario: Running ruby interactively Given an executable named "bin/aruba-test-cli" with: """bash diff --git a/features/03_testing_frameworks/cucumber/steps/command/run_commands_which_require_a_shell.feature b/features/03_testing_frameworks/cucumber/steps/command/run_commands_which_require_a_shell.feature index 8f5aa292f..1bf4dc1ec 100644 --- a/features/03_testing_frameworks/cucumber/steps/command/run_commands_which_require_a_shell.feature +++ b/features/03_testing_frameworks/cucumber/steps/command/run_commands_which_require_a_shell.feature @@ -4,9 +4,9 @@ Feature: Running shell commands - `When I run the following script:` Or you can run shell commands with: - - `I run the following (commands|script)` - - `I run the following (commands|script) (in|with) \`interpreter\`` - - `I run the following (commands|script) (in|with) \`/path/to/interpreter\`` + - `I run the following (commands|script):` + - `I run the following (commands|script) (in|with) \`interpreter\`:` + - `I run the following (commands|script) (in|with) \`/path/to/interpreter\`:` Background: Given I use a fixture named "cli-app" @@ -38,6 +38,7 @@ Feature: Running shell commands When I run `cucumber` Then the features should all pass + @requires-bash Scenario: Running shell commands Given a file named "features/shell.feature" with: """ @@ -52,106 +53,31 @@ Feature: Running shell commands When I run `cucumber` Then the features should all pass - @requires-bash - Scenario: Running bash commands - Given a file named "features/shell.feature" with: - """ - Feature: Running scripts - Scenario: Running bash commands - When I run the following commands with `bash`: - \"\"\"bash - echo "Hello `echo bash`" - \"\"\" - Then the output should contain exactly "Hello bash" - """ - When I run `cucumber` - Then the features should all pass - - @requires-zsh - Scenario: Running zsh commands - Given a file named "features/shell.feature" with: - """ - Feature: Running zsh scripts - Scenario: Running zsh commands - When I run the following commands with `zsh`: - \"\"\"bash - echo "Hello, Aruba!" - \"\"\" - Then the output should contain exactly "Hello, Aruba!" - """ - When I run `cucumber` - Then the features should all pass - - @requires-ruby - Scenario: Running ruby commands + Scenario: Running commands with a named interpreter Given a file named "features/shell.feature" with: """ Feature: Running scripts Scenario: Running ruby commands When I run the following commands with `ruby`: - \"\"\"ruby - puts "Hello, Aruba!" \"\"\" - Then the output should contain exactly "Hello, Aruba!" - """ - When I run `cucumber` - Then the features should all pass - - @requires-python - Scenario: Running python commands - Given a file named "features/shell.feature" with: - """ - Feature: Running scripts - Scenario: Running python commands - When I run the following commands with `python`: - \"\"\"python - print("Hello, Aruba!") + puts "Hello, Aruba!" \"\"\" Then the output should contain exactly "Hello, Aruba!" """ When I run `cucumber` Then the features should all pass - @requires-zsh + @requires-bash Scenario: Running commands if full path to interpreter is given Given a file named "features/shell.feature" with: """ - Feature: Running full path zsh - Scenario: Running zsh commands #1 - When I run the following commands with `/bin/zsh`: + Feature: Running full path + Scenario: Running full path bash + When I run the following commands with `/bin/bash`: \"\"\"bash - echo "Hello, Aruba!" + echo "Hello Aruba!" \"\"\" - Then the output should contain exactly "Hello, Aruba!" - - Scenario: Running zsh commands #1 - When I run the following commands in `/bin/zsh`: - \"\"\"bash - echo "Hello, Aruba!" - \"\"\" - Then the output should contain exactly "Hello, Aruba!" - """ - When I run `cucumber` - Then the features should all pass - - @requires-zsh - Scenario: Running commands if only the name of interpreter is given - Given a file named "features/shell.feature" with: - """ - Feature: Running full path zsh - Scenario: Running zsh commands #1 - When I run the following commands with `zsh`: - \"\"\"bash - echo "Hello, Aruba!" - \"\"\" - Then the output should contain exactly "Hello, Aruba!" - - Scenario: Running zsh commands #2 - When I run the following commands in `zsh`: - \"\"\"bash - echo "Hello, Aruba!" - \"\"\" - Then the output should contain exactly "Hello, Aruba!" + Then the output should contain "Hello Aruba!" """ When I run `cucumber` Then the features should all pass diff --git a/features/step_definitions/hooks.rb b/features/step_definitions/hooks.rb index 5db0297aa..415ad3339 100644 --- a/features/step_definitions/hooks.rb +++ b/features/step_definitions/hooks.rb @@ -6,16 +6,6 @@ skip_this_scenario end -Before '@requires-zsh' do |scenario| - next unless Aruba.platform.which('zsh').nil? - - if Cucumber::VERSION < '2' - scenario.skip_invoke! - else - skip_this_scenario - end -end - Before '@requires-java' do |scenario| next unless Aruba.platform.which('javac').nil? diff --git a/features/support/env.rb b/features/support/env.rb index 4e212b3f5..2517931e1 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,7 +1,7 @@ $LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__) # Has to be the first file required so that all other files show coverage information -require 'simplecov' +require 'simplecov' unless RUBY_PLATFORM.include?('java') # Standard Library require 'fileutils' @@ -9,6 +9,7 @@ # Gems require 'aruba/cucumber' +require 'aruba/config/jruby' require 'rspec/expectations' Before do |scenario| diff --git a/features/support/simplecov_setup.rb b/features/support/simplecov_setup.rb index ce13c7ef9..093a7ca7d 100644 --- a/features/support/simplecov_setup.rb +++ b/features/support/simplecov_setup.rb @@ -1,8 +1,11 @@ -# @note this file is loaded in env.rb to setup simplecov using RUBYOPTs for child processes and @in-process -require 'simplecov' +# @note this file is loaded in env.rb to setup simplecov using RUBYOPTs for +# child processes and @in-process +unless RUBY_PLATFORM.include?('java') + require 'simplecov' -root = File.expand_path('../../../', __FILE__) + root = File.expand_path('../../../', __FILE__) -SimpleCov.command_name(ENV['SIMPLECOV_COMMAND_NAME']) -SimpleCov.root(root) -load File.join(root, '.simplecov') + SimpleCov.command_name(ENV['SIMPLECOV_COMMAND_NAME']) + SimpleCov.root(root) + load File.join(root, '.simplecov') +end diff --git a/features/support/timing.rb b/features/support/timing.rb new file mode 100644 index 000000000..56a24f2f8 --- /dev/null +++ b/features/support/timing.rb @@ -0,0 +1,20 @@ +# From https://itshouldbeuseful.wordpress.com/2010/11/10/find-your-slowest-running-cucumber-features/ + +scenario_times = {} + +Around do |scenario, block| + name = "#{scenario.feature.file}::#{scenario.name}" + start = Time.now + block.call + end_time = Time.now + scenario_times[name] = end_time - start +end + +at_exit do + max_scenarios = scenario_times.size > 20 ? 20 : scenario_times.size + puts "------------- Top #{max_scenarios} slowest scenarios -------------" + sorted_times = scenario_times.sort { |a, b| b[1] <=> a[1] } + sorted_times[0..max_scenarios - 1].each do |key, value| + puts format("%.2f %s", value, key) + end +end diff --git a/lib/aruba/cucumber.rb b/lib/aruba/cucumber.rb index a8920028d..a8e3127f4 100644 --- a/lib/aruba/cucumber.rb +++ b/lib/aruba/cucumber.rb @@ -1,8 +1,6 @@ require 'aruba/version' require 'aruba/api' -World(Aruba::Api) - require 'aruba/cucumber/hooks' require 'aruba/cucumber/command' require 'aruba/cucumber/environment' diff --git a/spec/aruba/processes/spawn_process_spec.rb b/spec/aruba/processes/spawn_process_spec.rb index f0e6a3483..efc1aa37b 100644 --- a/spec/aruba/processes/spawn_process_spec.rb +++ b/spec/aruba/processes/spawn_process_spec.rb @@ -4,7 +4,7 @@ subject(:process) { described_class.new(command_line, exit_timeout, io_wait, working_directory) } let(:command_line) { 'echo "yo"' } - let(:exit_timeout) { 1 } + let(:exit_timeout) { 30 } let(:io_wait) { 1 } let(:working_directory) { Dir.getwd } @@ -24,20 +24,18 @@ describe '#stderr' do let(:command_line) { "ruby -e 'warn \"yo\"'" } - before(:each) { process.start } - before(:each) { process.stop } - - context 'when invoked once' do - it 'has the right args' do - expect(process.command).to eq 'ruby' - expect(process.arguments).to eq ['-e', 'warn "yo"'] - end + before do + process.start + process.stop + end - it { expect(process.stderr.chomp).to eq 'yo' } + it 'returns the output of the process on stderr' do + expect(process).not_to be_timed_out + expect(process.stderr.chomp).to eq 'yo' end - context 'when invoked twice' do - it { 2.times { expect(process.stderr.chomp).to eq 'yo' } } + it 'returns the same result when invoked a second time' do + 2.times { expect(process.stderr.chomp).to eq 'yo' } end end @@ -181,4 +179,20 @@ end end end + + describe '#command' do + let(:command_line) { "ruby -e 'warn \"yo\"'" } + + it 'returns the first item of the command line' do + expect(process.command).to eq 'ruby' + end + end + + describe '#arguments' do + let(:command_line) { "ruby -e 'warn \"yo\"'" } + + it 'handles arguments delimited with quotes' do + expect(process.arguments).to eq ['-e', 'warn "yo"'] + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c13d31560..b0d14f07e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,10 @@ $LOAD_PATH << ::File.expand_path('../../lib', __FILE__) -require 'simplecov' -SimpleCov.command_name 'rspec' -SimpleCov.start +unless RUBY_PLATFORM.include?('java') + require 'simplecov' + SimpleCov.command_name 'rspec' + SimpleCov.start +end # Pull in all of the gems including those in the `test` group require 'bundler' diff --git a/spec/support/configs/aruba.rb b/spec/support/configs/aruba.rb index 4e02754fc..a244ecb19 100644 --- a/spec/support/configs/aruba.rb +++ b/spec/support/configs/aruba.rb @@ -1,4 +1,5 @@ require 'aruba/rspec' +require 'aruba/config/jruby' Aruba.configure do |config| config.activate_announcer_on_command_failure = [:stderr, :stdout, :command]