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

Prevent load errors from killing the jruby-rspec guard #28

Merged
merged 1 commit into from
May 15, 2013

Conversation

nilbus
Copy link
Collaborator

@nilbus nilbus commented May 15, 2013

After guard starts, if a class was changed in a way that caused an error to be raised on load, the error was raising up into the guard stack, which caused the jruby-rspec guard to get fired / deactivated. Guard needed to be reloaded to continue testing.

20:30:52 - ERROR - Guard::JRubyRSpec failed to achieve its <run_on_changes>, exception was:
> [#] NameError: undefined local variable or method `crap' for #<Class:0x239e06d7>
> [#] org/jruby/RubyKernel.java:227:in `method_missing'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/.bundle/jruby/1.8/gems/activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
> [#] ./app/models/address.rb:2:in `Address'
> [#] ./app/models/address.rb:1:in `(root)'
> [#] org/jruby/RubyKernel.java:1058:in `load'
> [#] org/jruby/RubyMethod.java:133:in `call'
> [#] ./app/models/address.rb:88:in `reload_paths'
> [#] org/jruby/RubyArray.java:1615:in `each'
> [#] /vagrant/git/guard-jruby-rspec/lib/guard/jruby-rspec.rb:73:in `reload_paths'
> [#] /vagrant/git/guard-jruby-rspec/lib/guard/jruby-rspec.rb:54:in `run_on_changes'
> [#] org/jruby/RubyKernel.java:2080:in `send'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:99:in `run_supervised_task'
> [#] org/jruby/RubyKernel.java:1183:in `catch'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:97:in `run_supervised_task'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:144:in `run_first_task_found'
> [#] org/jruby/RubyArray.java:1615:in `each'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:142:in `run_first_task_found'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:79:in `run_on_changes'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:175:in `scoped_guards'> [#] org/jruby/RubyArray.java:1615:in `each'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:173:in `scoped_guards'
> [#] org/jruby/RubyKernel.java:1183:in `catch'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:172:in `scoped_guards'
> [#] org/jruby/RubyArray.java:1615:in `each'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:170:in `scoped_guards'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard/runner.rb:72:in `run_on_changes'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard.rb:105:in `setup_listener'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard.rb:368:in `within_preserved_state'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard.rb:365:in `within_preserved_state'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/guard-1.8.0/lib/guard.rb:104:in `setup_listener'
> [#] org/jruby/RubyProc.java:270:in `call'
> [#] org/jruby/RubyProc.java:220:in `call'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/listen-1.0.2/lib/listen/listener.rb:234:in `on_change'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/listen-1.0.2/lib/listen/listener.rb:266:in `initialize_adapter'
> [#] org/jruby/RubyProc.java:270:in `call'
> [#] org/jruby/RubyProc.java:220:in `call'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/listen-1.0.2/lib/listen/adapters/polling.rb:48:in `poll_changed_directories'
> [#] /home/vagrant/ws/rental_express/ROOT/rails/vendor/gems/listen-1.0.2/lib/listen/adapter.rb:284:in `start_poller'
> [#] org/jruby/RubyProc.java:270:in `call'
> [#] org/jruby/RubyProc.java:224:in `call'
21:13:33 - INFO - Guard::JRubyRSpec has just been fired

This patch instead outputs the error and its stacktrace using Guard::UI.error, cancels the current test run, and continues listening for changes.

Instead output the error and its stacktrace using guard, and cancel the test run.
@nilbus
Copy link
Collaborator Author

nilbus commented May 15, 2013

This problem doesn't exist in guard-rspec because it performs all of its runs in a separate process using system or DRb. This is necessary since the rspec tests run in the guard process.

jkutner added a commit that referenced this pull request May 15, 2013
Prevent load errors from killing the jruby-rspec guard
@jkutner jkutner merged commit 739ddfe into jkutner:master May 15, 2013
@jkutner
Copy link
Owner

jkutner commented May 15, 2013

Awesome! good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants