Skip to content

Commit

Permalink
Merge pull request #266 from akiellor/jruby-backtraces
Browse files Browse the repository at this point in the history
Fix ignoring of JRuby backtraces.
  • Loading branch information
mattwynne committed Apr 21, 2012
2 parents 7b01537 + 181e7c2 commit 7ca542c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cucumber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ end
default: <%= std_opts %> --dotcucumber features/.cucumber
jruby: <%= std_opts %> --tags ~@spork --tags ~@wire
jruby_win: <%= std_opts %> --tags ~@spork --tags ~@wire CUCUMBER_FORWARD_SLASH_PATHS=true
windows_mri: <%= std_opts %> --tags ~@spork --tags ~@wire --tags ~@needs-many-fonts CUCUMBER_FORWARD_SLASH_PATHS=true
ruby_1_9: <%= std_opts %> --tags ~@fails_on_1_9
windows_mri: <%= std_opts %> --tags ~@jruby --tags ~@spork --tags ~@wire --tags ~@needs-many-fonts CUCUMBER_FORWARD_SLASH_PATHS=true
ruby_1_9: <%= std_opts %> --tags ~@jruby --tags ~@fails_on_1_9
wip: --tags @wip:3 --wip features
none: --format pretty
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
36 changes: 36 additions & 0 deletions features/backtraces.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Feature: Backtraces
In order to discover errors quickly
As a cuker
I want to see backtraces for failures

Background:
Given a file named "features/failing_hard.feature" with:
"""
Feature: Sample
Scenario: Example
Given failing
"""

@jruby
Scenario: Backtraces enabled
Given a file named "features/step_definitions/steps.rb" with:
"""
require 'java'
java_import 'java.util.Collections'
Given /^failing$/ do
Collections.empty_list.add 1
end
"""
When I run `cucumber features/failing_hard.feature`
Then it should fail with:
"""
Feature: Sample
Scenario: Example # features/failing_hard.feature:2
Given failing # features/step_definitions/steps.rb:4
java.lang.UnsupportedOperationException: null (NativeException)
java/util/AbstractList.java:131:in `add'
java/util/AbstractList.java:91:in `add'
"""

14 changes: 0 additions & 14 deletions lib/cucumber/ast/step_invocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,6 @@ def find_step_match!(step_mother, configuration)
end

def failed(configuration, e, clear_backtrace)
if Cucumber::JRUBY && e.class.name == 'NativeException'
# JRuby's NativeException ignores #set_backtrace.
# We're fixing it.
e.instance_eval do
def set_backtrace(backtrace)
@backtrace = backtrace
end

def backtrace
@backtrace
end
end
end

e.set_backtrace([]) if e.backtrace.nil? || clear_backtrace
e.backtrace << @step.backtrace_line unless @step.backtrace_line.nil?
e = filter_backtrace(e)
Expand Down

0 comments on commit 7ca542c

Please sign in to comment.