Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent backtrace accross MRI versions #383

Closed
wants to merge 2 commits into from
Closed

Conversation

mattwynne
Copy link
Member

No description provided.

@dchelimsky this fails for me as you described on 1.8.7, but it's
passing in both 1.9.3 and 2.0.0. Do you have 2.0.0p0? Can you see
anything significanly different in my example to yours?
@tooky
Copy link
Member

tooky commented Mar 21, 2013

I've just been taking a look at this, as I've seen differences in backtraces reported between different versions of ruby while working on #399.

Travis output for #399 shows different ruby implementations reporting different line locations for the same exception.

I think this is also the case here.

I've made a quick change to @dchelimsky's repo to force an error without running cucumber, and show the backtrace.

git clone https://github.com/tooky/cucumber-output-example.git
cd cucumber-output-example
rvm 1.8.7@cucumber-output-example --create
bundle
ruby bin/codebreaker
rvm 1.9.3@cucumber-output-example --create
bundle
ruby bin/codebreaker
rvm 2.0.0@cucumber-output-example --create
bundle
ruby bin/codebreaker
rvm jruby-1.8.7@cucumber-output-example --create
bundle
ruby bin/codebreaker

Here is the output

#ruby 1.8.7
    ["bin/codebreaker:8:in `start'", "bin/codebreaker:8"]
    bin/codebreaker:8:in `start': wrong number of arguments (1 for 0) (ArgumentError)
            from bin/codebreaker:8

#ruby 1.9.3
    ["/Users/steve/tmp/cucumber-output-example/lib/codebreaker/game.rb:7:in `start'",
     "bin/codebreaker:8:in `<main>'"]
    /Users/steve/tmp/cucumber-output-example/lib/codebreaker/game.rb:7:in `start': wrong number of arguments (1 for 0) (ArgumentError)
        from bin/codebreaker:8:in `<main>'

#ruby 2.0.0
    ["/Users/steve/tmp/cucumber-output-example/lib/codebreaker/game.rb:7:in `start'",
     "bin/codebreaker:8:in `<main>'"]
    /Users/steve/tmp/cucumber-output-example/lib/codebreaker/game.rb:7:in `start': wrong number of arguments (1 for 0) (ArgumentError)
        from bin/codebreaker:8:in `<main>'

#jruby 1.7.3 (1.9.3p385)
    ["bin/codebreaker:8:in `(root)'"]
    ArgumentError: wrong number of arguments calling `start` (1 for 0)
      (root) at bin/codebreaker:8

@mattwynne - not sure we'll be able to work around this?

@mattwynne
Copy link
Member Author

So @tooky are you saying that this is Ruby, rather than Cucumber behaviour?

@dchelimsky what motivated you to notice / report this in the first place? Was it just a curiosity or is there something you're trying to achieve that we could maybe work around some other way?

@dchelimsky
Copy link
Contributor

I'm working on an update to The RSpec Book to bring it up to date with the latest versions of Ruby and assorted gems.

The important thing is not getting identical, character by character output but that we get a pointer to the place we can fix the failure. Here's the output from my original example:

# ruby 1.8.7
      wrong number of arguments (1 for 0) (ArgumentError)
      ./features/step_definitions/codebreaker_steps.rb:21:in `start'
      ./features/step_definitions/codebreaker_steps.rb:21:in `/^the secret code is "([^"]*)"$/'
      features/codebreaker_submits_guess.feature:12:in `Given the secret code is "<code>"'

# ruby 1.9.3
      wrong number of arguments (1 for 0) (ArgumentError)
      ./lib/codebreaker/game.rb:7:in `start'
      ./features/step_definitions/codebreaker_steps.rb:21:in `/^the secret code is "([^"]*)"$/'
      features/codebreaker_submits_guess.feature:12:in `Given the secret code is "<code>"'

# ruby 2.0.0
      wrong number of arguments (1 for 0) (ArgumentError)
      ./lib/codebreaker/game.rb:7:in `/^the secret code is "([^"]*)"$/'
      features/codebreaker_submits_guess.feature:12:in `Given the secret code is "<code>"'

The error is due to ./features/step_definitions/codebreaker_steps.rb:21 invoking the method on ./lib/codebreaker/game.rb:7 incorrectly. The information provided in Ruby 1.8.7 and 1.9.3, though different from each other, provides at least one pointer to ./features/step_definitions/codebreaker_steps.rb:21, which is the call site - the point where the problem can be fixed. In Ruby 2.0.0 there is no reference to that line, so the user is left reasoning about how to get from features/codebreaker_submits_guess.feature:12 to lib/codebreaker/game.rb:7. I'm less concerned with having two references to ./features/step_definitions/codebreaker_steps.rb:21 in Ruby 1.8.7 than I am with no references in Ruby 2.0.0.

Make sense?

@tooky
Copy link
Member

tooky commented Mar 26, 2013

@dchelimsky I'm not able to reproduce that on ruby 2.0 here.

I'm getting

# ruby -v
# ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.3.0]

      wrong number of arguments (1 for 0) (ArgumentError)
      ./lib/codebreaker/game.rb:7:in `start'
      ./features/step_definitions/codebreaker_steps.rb:21:in `/^the secret code is "([^"]*)"$/'
      features/codebreaker_submits_guess.feature:12:in `Given the secret code is "<code>"'

Which matches 1.9.3.

@mattwynne - should we set up a ruby 2.0.0 build on travis? The feature in this PR passes for me on 2.0.0.

@mattwynne
Copy link
Member Author

On 26 Mar 2013, at 13:09, Steve Tooke notifications@github.com wrote:

@mattwynne - should we set up a ruby 2.0.0 build on travis? The feature in this PR passes for me on 2.0.0.

It should already be building 2.0.0

@mattwynne
Copy link
Member Author

I think this has been fixed, somehow, in a recent version of Cucumber. I seem to be able to get the step definition line to appear in the backtrace in Ruby 2.0.0 by using master, or 1.2.3.

@dchelimsky can you try again using cucumber version 1.2.3 please?

@mattwynne
Copy link
Member Author

Yeah in fact looking at History.md we didn't even support Ruby 2.0.0 until Cucumber 1.2.2 - that might have had something to do with it!

@dchelimsky
Copy link
Contributor

Works as I expect with 1.2.3. Looks like 1.2.2 (which also works as I expect) came out the day after I filed this issue :)

@mattwynne
Copy link
Member Author

Happy days!

@mattwynne mattwynne closed this Mar 26, 2013
@mattwynne mattwynne deleted the fix-issue-381 branch March 26, 2013 14:16
@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants