Cucumber won't run with Spork

I can run my cucumber tests without a Drb, but Cucumber raises an exception when I try to run using Spork. The stack crawl is below. I am running RM 2.0.2 RC (RM-93.130). BTW the problem also occurs running without the debugger.

2 Questions:

  1. how do I fix/work-around the problem
  2. can you recommend directions for how to debug the tests running under Drb? I tried setting a breakpoint in the code based on the stack crawl, and it when I ran it again, the breakpoint was hit once, and as far as I could tell the exception wasn't raised, but continuing from that point ended up with the stack crawl below.


/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) /home/jeff/.gem/ruby/1.8/bin/rdebug-ide --port 44024 -- /home/jeff/projects/foo/script/cucumber /home/jeff/projects/foo/features/manage_gtds.feature --format Teamcity::Cucumber::Formatter --expand --color
Testing started at 12:07 AM ...
Fast Debugger (ruby-debug-ide 0.4.9) listens on :44024
Using the default profile...
Disabling profiles...
Exception encountered: #<RuntimeError: All but one formatter must use --out, only one can print to each stream (or STDOUT)>
backtrace:
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/lib/cucumber/cli/configuration.rb:173:in `arrange_formats'
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/lib/cucumber/cli/configuration.rb:26:in `parse!'
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/lib/cucumber/cli/main.rb:91:in `configuration'
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/lib/cucumber/cli/main.rb:38:in `execute!'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/test_framework/cucumber.rb:22:in `run_tests'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/forking.rb:13:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/magazine/../../../spork/forker.rb:21:in `initialize'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/magazine/../../../spork/forker.rb:18:in `fork'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/magazine/../../../spork/forker.rb:18:in `initialize'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/forking.rb:9:in `new'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/forking.rb:9:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/server.rb:47:in `run'
/usr/lib/ruby/1.8/drb/drb.rb:1563:in `__send__'
/usr/lib/ruby/1.8/drb/drb.rb:1563:in `perform_without_block'
/usr/lib/ruby/1.8/drb/drb.rb:1523:in `perform'
/usr/lib/ruby/1.8/drb/drb.rb:1597:in `main_loop'
/usr/lib/ruby/1.8/drb/drb.rb:1593:in `loop'
/usr/lib/ruby/1.8/drb/drb.rb:1593:in `main_loop'
/usr/lib/ruby/1.8/drb/drb.rb:1589:in `start'
/usr/lib/ruby/1.8/drb/drb.rb:1589:in `main_loop'
/usr/lib/ruby/1.8/drb/drb.rb:1438:in `run'
/usr/lib/ruby/1.8/drb/drb.rb:1435:in `start'
/usr/lib/ruby/1.8/drb/drb.rb:1435:in `run'
/usr/lib/ruby/1.8/drb/drb.rb:1355:in `initialize'
/usr/lib/ruby/1.8/drb/drb.rb:1635:in `new'
/usr/lib/ruby/1.8/drb/drb.rb:1635:in `start_service'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/server.rb:29:in `listen'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/server.rb:20:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/bin/../lib/spork/runner.rb:75:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/bin/../lib/spork/runner.rb:9:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/bin/spork:10
/home/jeff/.gem/ruby/1.8/bin/spork:19:in `load'
/home/jeff/.gem/ruby/1.8/bin/spork:19
-e:1:in `load'
-e:1
    /home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/bin/cucumber:11:in `exit'
    /home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/bin/cucumber:11
    /home/jeff/projects/foo/script/cucumber:9:in `load'
    /home/jeff/projects/foo/script/cucumber:9
    /home/jeff/.gem/ruby/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in `debug_load'
    /home/jeff/.gem/ruby/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in `debug_program'
    /home/jeff/.gem/ruby/1.8/gems/ruby-debug-ide-0.4.9/bin/rdebug-ide:87
    /home/jeff/.gem/ruby/1.8/bin/rdebug-ide:19:in `load'
    /home/jeff/.gem/ruby/1.8/bin/rdebug-ide:19
    -e:1:in `load'
    -e:1
Uncaught exception: exit
Empty test suite.

Process finished with exit code 0

10 comments

Hi guys,

It's a Cucumber bug. See details and workaround in http://youtrack.jetbrains.net/issue/RUBY-5920 issue

0

Hi Roman,

Thanks for being so responsive (as usual =). I'm enough of a cucumber/rails newbie that I'm going to need you to indicate the specific changes to the cucumber.yml file. I took a look at my rerun.txt file, and it existed but was empty. So, the rerun_opts local variable would resolve to just, "

--format progress features
", AFAIK.
I was able to get the cucumber tests to run by making the following changes:

- std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"

+ std_opts = "--format rerun --out rerun.txt --strict --tags ~@wip"


but I don't understand enough about the formatters and purpose of rerun to understand the impact of this change.

0

I don't understand enough about the formatters and purpose of rerun to understand the impact of this change.

Cucumber allows to subscribe listeners on it's internal events (feature started, step passed/failed/ignored, etc.). Such listeners represent tests results for user. RubyMine also provides a listener which is responsible to interaction with RubyMine test runner UI.

purpose of rerun


Rerun - is new feature of cucumber. At first tests launch cucumber will run all features in "features" folder. Then "rerun" formatter will save failed features names in rerun.txt file. At second launch cucumber will run only failed features mentioned in rerun.txt. If rerun.txt is empty cucumber will run all features in project again. RubyMine doesn't know about this new cucumber feature and doesn't support it (see http://youtrack.jetbrains.net/issue/RUBY-5922, http://youtrack.jetbrains.net/issue/RUBY-5923). RubyMine always passes name of feature file/folder which you want to test and overrides "rerun" behaviour.

the impact of this change.


Cucumber doesn't allow to use more than 1 formatter which outputs data to stdout stream, all other formatters must redirect their output to some file

So, the rerun_opts local variable would resolve to just, "

--format progress features
"

Firstly RubyMine attaches our custom tests results formatter (just to show results in nice GUI) to $stdout and then cucumber.yml also attaches "progress" formatter. So you will get "Exception encountered: #<RuntimeError: All but one formatter must use --out, only one can print to each stream (or STDOUT)>" error.

And here you can notice

--format rerun --out rerun.txt

that "rerun" formatter redirects output to rerun.txt

Your cucumer.yml may be

<%% rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" rerun_opts = rerun.to_s.strip.empty? ? "features" : "#{rerun}" std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip" %>
default: <%= spork? ? '--drb ' : '' %><%%= std_opts %>
default_console: <%= spork? ? '--drb ' : '' %><%%= std_opts %> --format pretty



Future RubyMine builds will allow you to use cucumber's "rerun" feature. If you don't want to keep "rerun" behaviour - just use

default: ~@wip
...



or

default:
....

0

Excellent, excellent explanation, Roman. Thank you.

0

Exception encountered: #<Errno::ENOENT: No such file or directory - Teamcity::Cucumber::Formatter>
backtrace:


I finally fixed this Issue, thanks to this post:
https://rspec.lighthouseapp.com/projects/16211/tickets/597-cucumber-fails-when-tests-are-launched-from-rubymine-using-spork


EDIT cucumber.yml

not working
 

<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: --drb <%= std_opts %> features
wip: --drb --tags @wip:3 --wip features
rerun: --drb <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip





working

<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: --drb <%= std_opts %>
wip: --drb --tags @wip:3 --wip features
rerun: --drb <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip


Tested with:
Rails 3.0.6

1. spork-0.8.4
2. spork-0.9.0.rc5

cucumber (0.10.2)
cucumber-rails (0.4.1)


Hopefully anybody else has less hours to figure out this.
Caution:

rails g cucumber:install generates it with the option "features"
So you only have to remove this word and voilà!

0

Thank you for the investigation and workaround!

0

By the way, I'm using a cucumber.yml generated by cucumber 0.10.2 and cucumber+spork works out of the box. My cucumber.yml:

<% rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" %> default: <%= std_opts %> features wip: --tags @wip:3 --wip features rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip

0

That doesn't run with the drb service though --- no '--drb' in the command line.

I'm trying to get Cucumber working with Spork at the moment, and not having much joy.  I'll just give up for the time being. :|

0

Geoff,

Which cucumber gem version do you use?

0

Please sign in to leave a comment.