sunaku / tork

💞 Tests your Ruby code, in parallel, as you change it
https://sunaku.github.io/tork/man
Other
179 stars 14 forks source link

Test failure shows stack trace instead of rspec output #11

Closed pwightman closed 13 years ago

pwightman commented 13 years ago

I followed the installation instructions closely and when running a failing rspec test, it prints out a stack trace instead of the RSpec output. Is this how it's supposed to work? It doesn't even tell me what line it failed on, which makes the output more or less useless. I can always re-run the test manually to see the RSpec output, but I just wondered if this was normal or not, I can't find anywhere indicating what's supposed to print out on failed tests.

Thanks! I love the ease of setup instead of needing to install several gems to accomplish the same thing, thanks for the good work.

sunaku commented 13 years ago

When a test file fails, test-loop simply prints its log file to STDOUT for your convenience. In the following example, I'm getting rspec output plus a stack trace that includes test-loop stuff (which I just mentally ignore). Do you get something totally different?

$ cat spec/spec_helper.rb
require 'rspec/autorun'

$ cat spec/game_spec.rb
class Game
  def roll(pins)
  end

  def score
    0
  end
end

describe Game do
  describe "#score" do
    it "returns 0 for all gutter game" do
      game = Game.new
      20.times { game.roll(0) }
      game.score.should == 0
    end

    it "returns over nine thousand" do
      game = Game.new
      game.score.should > 9000
    end
  end
end

$ test-loop
test-loop: Absorbing overhead...
test-loop: Ready for testing!
test-loop: Running all tests...
test-loop: TEST spec/game_spec.rb
test-loop: FAIL spec/game_spec.rb
.F

Failures:

  1) Game#score returns over nine thousand
     Failure/Error: game.score.should > 9000
       expected: > 9000
            got:   0
     # spec/game_spec.rb:20:in `block (3 levels) in <top (required)>'
     # lib/test/loop.rb:248:in `fork'
     # lib/test/loop.rb:248:in `fork_worker'
     # lib/test/loop.rb:184:in `block (2 levels) in enter_testing_loop'
     # lib/test/loop.rb:183:in `each'
     # lib/test/loop.rb:183:in `block in enter_testing_loop'
     # lib/test/loop.rb:151:in `loop'
     # lib/test/loop.rb:151:in `enter_testing_loop'
     # lib/test/loop.rb:63:in `run'

Finished in 0.00104 seconds
2 examples, 1 failure

Failed examples:

rspec spec/game_spec.rb:18 # Game#score returns over nine thousand
pwightman commented 13 years ago

I get the following. At first I thought maybe I just had syntax errors, but I've check and re-checked to make sure it's just a test failing and not anything syntactical. It might be worth mentioning that I get proper output when tests pass, this only happens when they fail. Any ideas?

Thanks,

/Users/parkerwightman/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:581:in `block in process_args': invalid option: --example (OptionParser::InvalidOption)
    from /Users/parkerwightman/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:560:in `new'
    from /Users/parkerwightman/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:560:in `process_args'
    from /Users/parkerwightman/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:591:in `run'
    from /Users/parkerwightman/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:508:in `block in autorun'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/lib/test/loop.rb:248:in `fork'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/lib/test/loop.rb:248:in `fork_worker'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/lib/test/loop.rb:184:in `block (2 levels) in enter_testing_loop'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/lib/test/loop.rb:183:in `each'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/lib/test/loop.rb:183:in `block in enter_testing_loop'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/lib/test/loop.rb:151:in `loop'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/lib/test/loop.rb:151:in `enter_testing_loop'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/lib/test/loop.rb:63:in `run'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/gems/test-loop-12.3.1/bin/test-loop:3:in `<top (required)>'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/bin/test-loop:19:in `load'
    from /Users/parkerwightman/.rvm/gems/ruby-1.9.2-p290@hpt/bin/test-loop:19:in `<main>'
sunaku commented 13 years ago

Well here's the root problem. You say you're using RSpec but really the minitest library is in use:

/Users/parkerwightman/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/_minitest****_/unit.rb:581:in `block in process_args': invalid option: --example (OptionParser::InvalidOption)

Please verify that your spec/spec_helper.rb file loads RSpec correctly:

$ cat spec/spec_helper.rb
require 'rspec/autorun'

And also ensure that there is no test/test_helper.rb file in your source tree because I don't think it's possible to use Minitest and RSpec simultaneously.

edthix commented 13 years ago

Had the same issue with @pwightman

using rspec-rails 2.61

# spec/spec_helper.rb
require 'rspec/rails'

And I've remove test/test_helper.rb file. Now when i run test-loop all my specs passes even the the failing ones. Running the specs from bundle exec seems to be fine.

sunaku commented 13 years ago

Are you guys sure that it's really RSpec running your specs and not Minitest?

Please add this line to the top of your spec_helper file and try re-run with test-loop:

require 'rspec/autorun'

Thanks.

edthix commented 13 years ago

Ah didn't catch that early on. So I did this:

#spec_helper
require 'rspec/autorun' # add this on top
require 'rspec/rails'

Now it works. Thanks :)

pwightman commented 13 years ago

I was having the same issue with it passing all my tests. I'm pretty sure I have both of those at the top of my spec helper but I'll give it a look tomorrow morning and see if it fixes it. Thanks for all your help!

On Aug 9, 2011, at 11:51 PM, edthix reply@reply.github.com wrote:

Ah didn't catch that early on. So I did this:

#spec_helper
require 'rspec/autorun' # add this on top
require 'rspec/rails'

Now it works. Thanks :)

Reply to this email directly or view it on GitHub: https://github.com/sunaku/test-loop/issues/11#issuecomment-1770062

sunaku commented 13 years ago

Any news @pwightman? Problem solved?

pwightman commented 13 years ago

Sorry for the delay, I've been out of town. I did have both of those lines in my spec file, and deleted all files related to test unit, still without success. Every test would still "pass", which probably means it's not running RSpec at all, as you alluded to earlier. However, now RSpec itself is throwing "Uninitialized constant: ActiveModel" errors now matter how I run it that I haven't been able to solve, however my problems it's beyond the scope of this gem at this point :-) I thank you for your help, but the issue can probably close at this point until I figure out what's going on.