serpapi / turbo_tests

Run RSpec tests on multiple cores. Like parallel_tests but with incremental summarized output. Originally extracted from the Discourse and Rubygems source code.
https://rubygems.org/gems/turbo_tests
MIT License
172 stars 26 forks source link

NoMethodError: undefined method `pending_exception' for TurboTests::FakeExecutionResult #6

Closed Xanthus closed 3 years ago

Xanthus commented 3 years ago

Cool project, thought I'd give it a try. Getting the following error below. I'm not sure which spec line is producing the error as I haven't spent time digging. If you want me to try something to figure it out let me know.

Extract from Gemfile.lock:

    parallel (1.20.1)
    parallel_tests (3.4.0)
      parallel
...
    rails (6.0.3.4)
...
    rspec (3.10.0)
      rspec-core (~> 3.10.0)
      rspec-expectations (~> 3.10.0)
      rspec-mocks (~> 3.10.0)
    rspec-cells (0.3.5)
      cells (>= 4.0.0, < 6.0.0)
      rspec-rails (< 5.0)
    rspec-core (3.10.0)
      rspec-support (~> 3.10.0)
    rspec-expectations (3.10.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.10.0)
    rspec-mocks (3.10.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.10.0)
    rspec-rails (4.0.1)
      actionpack (>= 4.2)
      activesupport (>= 4.2)
      railties (>= 4.2)
      rspec-core (~> 3.9)
      rspec-expectations (~> 3.9)
      rspec-mocks (~> 3.9)
      rspec-support (~> 3.9)
    rspec-support (3.10.0)
...
    turbo_tests (1.2.0)
      bundler
      parallel_tests (~> 3.3)
      rspec (~> 3.10.0)
...
RUBY VERSION
   ruby 2.7.2p137

BUNDLED WITH
   2.1.4

Exception:

root@864e496ab0b5:/usr/local/app# bundle exec turbo_tests

[TRUNCATED]

FFF.F.F.F.F.F...bundler: failed to load command: turbo_tests (/usr/local/gemcache/ruby/2.7.0/bin/turbo_tests)
NoMethodError: undefined method `pending_exception' for #<TurboTests::FakeExecutionResult:0x000055f5244afed8>
Did you mean?  pending_fixed?
  /usr/local/gemcache/ruby/2.7.0/gems/rspec-core-3.10.0/lib/rspec/core/formatters/exception_presenter.rb:291:in `initialize'
  /usr/local/gemcache/ruby/2.7.0/gems/rspec-core-3.10.0/lib/rspec/core/notifications.rb:211:in `new'
  /usr/local/gemcache/ruby/2.7.0/gems/rspec-core-3.10.0/lib/rspec/core/notifications.rb:211:in `initialize'
  /usr/local/gemcache/ruby/2.7.0/gems/rspec-core-3.10.0/lib/rspec/core/notifications.rb:55:in `new'
  /usr/local/gemcache/ruby/2.7.0/gems/rspec-core-3.10.0/lib/rspec/core/notifications.rb:55:in `for'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/lib/turbo_tests.rb:77:in `notification'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/lib/turbo_tests/reporter.rb:55:in `example_pending'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/lib/turbo_tests/runner.rb:162:in `block in handle_messages'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/lib/turbo_tests/runner.rb:154:in `loop'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/lib/turbo_tests/runner.rb:154:in `handle_messages'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/lib/turbo_tests/runner.rb:63:in `run'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/lib/turbo_tests/runner.rb:26:in `run'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/lib/turbo_tests/cli.rb:89:in `run'
  /usr/local/gemcache/ruby/2.7.0/gems/turbo_tests-1.2.0/bin/turbo_tests:11:in `<top (required)>'
  /usr/local/gemcache/ruby/2.7.0/bin/turbo_tests:23:in `load'
  /usr/local/gemcache/ruby/2.7.0/bin/turbo_tests:23:in `<top (required)>'
ilyazub commented 3 years ago

@Xanthus Thanks for the bug report. Please share a minimal code example that fails with this error. I already have a possible fix in my mind, but want to make sure your case will be also fixed.

Possible fix I'll check later:

diff --git a/lib/turbo_tests.rb b/lib/turbo_tests.rb
index ade2335..8621d46 100644
--- a/lib/turbo_tests.rb
+++ b/lib/turbo_tests.rb
@@ -36,7 +36,7 @@ module TurboTests
     end
   end

-  FakeExecutionResult = Struct.new(:example_skipped?, :pending_message, :status, :pending_fixed?, :exception)
+  FakeExecutionResult = Struct.new(:example_skipped?, :pending_message, :status, :pending_fixed?, :exception, :pending_exception)
   class FakeExecutionResult
     def self.from_obj(obj)
       new(
@@ -44,6 +44,7 @@ module TurboTests
         obj["pending_message"],
         obj["status"].to_sym,
         obj["pending_fixed?"],
+        FakeException.from_obj(obj["exception"]),
         FakeException.from_obj(obj["exception"])
       )
     end
wwahammy commented 3 years ago

I'm also having this error.

ilyazub commented 3 years ago

@wwahammy Please share a minimal code example that fails with this error.

louim commented 3 years ago

Any pending example from RSpec will trigger the problem: https://relishapp.com/rspec/rspec-core/v/3-10/docs/pending-and-skipped-examples/pending-examples. This will fail:

describe "an example" do
  it "is implemented but waiting" do
    pending("something else getting finished")
    raise
  end
end
wwahammy commented 3 years ago

Thank you for tracking it down @louim. This is been on my unending to-do list :+1:

louim commented 3 years ago

@ilyazub: I tried your fix, but it gets stuck later on:

/Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:272:in `exception_backtrace': undefined method `backtrace' for nil:NilClass (NoMethodError)
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:245:in `find_failed_line'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:218:in `read_failed_lines'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:166:in `failure_slash_error_lines'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:153:in `block in failure_lines'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:152:in `tap'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:152:in `failure_lines'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:34:in `colorized_message_lines'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:253:in `formatted_message_and_backtrace'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:88:in `fully_formatted_lines'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/exception_presenter.rb:80:in `fully_formatted'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/notifications.rb:200:in `fully_formatted'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/notifications.rb:126:in `block in fully_formatted_pending_examples'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/notifications.rb:125:in `each'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/notifications.rb:125:in `each_with_index'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/notifications.rb:125:in `fully_formatted_pending_examples'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters/base_text_formatter.rb:49:in `dump_pending'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/turbo_tests-1.2.4/lib/turbo_tests/reporter.rb:121:in `block in delegate_to_formatters'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/turbo_tests-1.2.4/lib/turbo_tests/reporter.rb:120:in `each'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/turbo_tests-1.2.4/lib/turbo_tests/reporter.rb:120:in `delegate_to_formatters'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/turbo_tests-1.2.4/lib/turbo_tests/reporter.rb:96:in `finish'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/turbo_tests-1.2.4/lib/turbo_tests/runner.rb:92:in `run'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/turbo_tests-1.2.4/lib/turbo_tests/runner.rb:36:in `run'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/turbo_tests-1.2.4/lib/turbo_tests/cli.rb:89:in `run'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/turbo_tests-1.2.4/bin/turbo_tests:11:in `<top (required)>'
    from /Users/louim/.asdf/installs/ruby/2.6.8/bin/turbo_tests:23:in `load'
    from /Users/louim/.asdf/installs/ruby/2.6.8/bin/turbo_tests:23:in `<top (required)>'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/cli/exec.rb:63:in `load'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/cli/exec.rb:63:in `kernel_load'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/cli/exec.rb:28:in `run'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/cli.rb:481:in `exec'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/cli.rb:31:in `dispatch'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/cli.rb:25:in `start'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/exe/bundle:49:in `block in <top (required)>'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
    from /Users/louim/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/bundler-2.2.25/exe/bundle:37:in `<top (required)>'
    from /Users/louim/.asdf/installs/ruby/2.6.8/bin/bundle:23:in `load'
    from /Users/louim/.asdf/installs/ruby/2.6.8/bin/bundle:23:in `<main>'

I have not dug down further.

ilyazub commented 3 years ago

@louim I found a problem and preparing the solution. Thank you for the minimal reproducible example :rocket:

ilyazub commented 3 years ago

PR with a fix: #15. Feel free to test and review it.

ilyazub commented 3 years ago

Fixed in v1.2.5.