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

Improve rake task report on failure #400

Merged
merged 7 commits into from
Mar 27, 2013
Merged

Improve rake task report on failure #400

merged 7 commits into from
Mar 27, 2013

Conversation

avakarev
Copy link
Contributor

It will clean up output from rake's "rake aborted!" reports on failures.
Failure in this case when sh method got exit status != 0

Before:

$:> rake
/Users/avakarev/.rvm/rubies/ruby-1.9.3-p392/bin/ruby -S bundle exec cucumber --format pretty
Feature: List
  In order to be informed how many there are items
  I want to be able to see all of those items as a list

  Scenario: List an items       # features/list.feature:5
    Given I am on the home page # features/step_definitions/web_steps.rb:1
      undefined local variable or method `go' for #<Object:0x007fef1510b240> (NameError)
      ./features/step_definitions/web_steps.rb:4:in `/^I am on the home page$/'
      features/list.feature:6:in `Given I am on the home page'
    Then I should see 4 items   # features/step_definitions/web_steps.rb:26

Failing Scenarios:
cucumber features/list.feature:5 # Scenario: List an items

1 scenario (1 failed)
2 steps (1 failed, 1 skipped)
0m1.500s
rake aborted!
Command failed with status (1): [/Users/avakarev/.rvm/rubies/ruby-1.9.3-p39...]
/Users/avakarev/.rvm/gems/ruby-1.9.3-p392/gems/cucumber-1.2.3/lib/cucumber/rake/task.rb:104:in `run'
/Users/avakarev/.rvm/gems/ruby-1.9.3-p392/gems/cucumber-1.2.3/lib/cucumber/rake/task.rb:197:in `block in define_task'
/Users/avakarev/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `eval'
/Users/avakarev/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => default => features
(See full trace by running task with --trace)

After:

$:> rake
/Users/avakarev/.rvm/rubies/ruby-1.9.3-p392/bin/ruby -S bundle exec cucumber --format pretty
Feature: List
  In order to be informed how many there are items
  I want to be able to see all of those items as a list

  Scenario: List an items       # features/list.feature:5
    Given I am on the home page # features/step_definitions/web_steps.rb:1
      undefined local variable or method `go' for #<Object:0x007faed4b0a790> (NameError)
      ./features/step_definitions/web_steps.rb:4:in `/^I am on the home page$/'
      features/list.feature:6:in `Given I am on the home page'
    Then I should see 4 items   # features/step_definitions/web_steps.rb:26

Failing Scenarios:
cucumber features/list.feature:5 # Scenario: List an items

1 scenario (1 failed)
2 steps (1 failed, 1 skipped)
0m1.494s

@os97673
Copy link
Member

os97673 commented Mar 19, 2013

Could you please add a test for this (so nobody breaks it in future)

@mattwynne
Copy link
Member

I echo Oleg's request for a test.

Can I just confirm (because I'm too lazy to check) that the rake task will still return non-zero exit status if the task fails? It would be useful if such a test proved that.

@avakarev
Copy link
Contributor Author

Thank you guys for your feedback.

@mattwynne
You are right. There is should be

exit res.exitstatus

in the block given to rake's sh.

So, PR is not finished yet.
I will add some changes and all the tests as soon as I will have some spare time.

@os97673
Copy link
Member

os97673 commented Mar 20, 2013

@avakarev please let us know when the PR will be ready for review

@mattwynne
Copy link
Member

Oleg, you're not asking him for an estimate are you? ;)

@os97673
Copy link
Member

os97673 commented Mar 21, 2013

Estimation? What a nice word, what does it mean? ;)
What I was really asking is to notify us AFTER the PR will be ready for review, so we wouldn't miss this.
(note to @os97673: need to proof-read all messages for possible incorrect interpretations :)

@avakarev
Copy link
Contributor Author

Here we go.
Please, review my PR.

sh(cmd.join(" "))
sh cmd.join(" ") do |ok, res|
# With this block, rake will not append its backtrace to
# cucumber's report on failures.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this comment. The git logs will point us to your commit messages and tell us why the code looks the way it does.

@mattwynne
Copy link
Member

Thanks @avakarev! I've added a few minor review comments.

@os97673 I was surprised to see the tests implemented as RSpec rather than Cucumber features. WDYT about that?

@avakarev
Copy link
Contributor Author

@mattwynne Thanks for your fast feedback. I've just noticed that Travis failed on ruby 1.8.7 and jruby suits. My fault regarding 1.8.7: there is no open3#popen2e. Trying to figure out what's wrong with jruby.

@mattwynne
Copy link
Member

On 21 Mar 2013, at 21:49, Andrey Vakarev [email protected] wrote:

@mattwynne Thanks for your fast feedback. I've just noticed that Travis failed on ruby 1.8.7 and jruby suits. My fault regarding 1.8.7: there is no open3#popen2e. Trying to figure out what's wrong with jruby.

One alternative might be to use a feature for the tests instead. Aruba has a nice cross-platform API for testing console apps. Have a look at a couple of the other features and you should get the idea.

@os97673
Copy link
Member

os97673 commented Mar 22, 2013

@os97673 I was surprised to see the tests implemented as RSpec rather than Cucumber features. WDYT about that?

@mattwynne I think this is because there is "rake" in spec name ;)
@avakarev is it possible to rewrite the test with cucumber. As far as I can see our specs do not execute cucumber and I think it would be better to keep all real cucumber's execution in our features. Also I think we have all support code you need there.

@avakarev
Copy link
Contributor Author

Yes. I will move tests to Cucumber's feature. And make sure that jruby works before committing :-)

@avakarev
Copy link
Contributor Author

Could you guys please review my last changes?
At the end, I'd like not to merge all my obsolete commits.
Maybe other PR with squash?

@mattwynne
Copy link
Member

Great!

Don't worry about the old commits, it's cool.

mattwynne added a commit that referenced this pull request Mar 27, 2013
…lure

Improve rake task report on failure
@mattwynne mattwynne merged commit dfb9cda into cucumber:master Mar 27, 2013
@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