Separate Defaults for Debug and Run configurations

Hi all,

I would like to be able to have a different set of Defaults for my Run and Debug configurations.  Is there a way to do this?

I usually setup my Run configuration to launch testdrb (spork client), so that my tests run through spork, and thus run quickly - our rails stack takes almost 30secs to load, which kills productivity when trying to run individual test cases.

For spork, I set the Defaults for Test::Unit/Shoulda to have the following as the Ruby arguments: "-I. -Itest -S testdrb", so that when I "Run context configuration" it sets up a new configuration and runs my test through spork with no hassle (Assuming the spork server is running :) ).  RubyMine doesn't have Spork support for TestUnit, so not sure if this would be necessary if it did.

However, once in a while I would also like to debug a test, but since the Run and Debug actions share the same configuration, and this default configuration calls testdrb, when I try to debug it also tries to go through testdrb and fails.

If I could setup the Default for Test::Unit/Shoulda Debug to be different from the Default for Test::Unit/Shoulda Run, then I wouldn't have this problem.  Is there a way to do this?  If not, is there some other way to accomplish the same thing?

While the above would keep me happy for now, in an ideal world I'd love to be able to debug through spork to make debugging as fast as running, but I don't think this is easy due to the forking action going on.  One would have to make rubymine run testdrb and then connect to the forked process instead of testdrb.  Maybe the "script" that is passed to spork through testdrb could cause rdebug to get loaded in the fork and connect back to the rubymine debugger port...?

Also, it would be great if I could get the same level of integration with spork that direct test execution has - e.g. being able to see the status while tests are running, be able to run individual tests, red/green status, etc.  Right now all I see is "No tests were found" in the left panel, even though they ran just fine in the right panel (understandable given the nature of fork, some kind of result parser needed?)

Any help appreciated, thanks,

Matt

5 comments
Comment actions Permalink

Hello Matt,

I would like to be able to have a different set of Defaults for my Run and Debug configurations.  Is there a way to do this?

Unfortunately such behaviour isn't supported

I usually setup my Run configuration to launch testdrb (spork client), so that my tests run through spork, and thus run quickly - our rails stack takes almost 30secs to load, which kills productivity when trying to run individual test cases.

For spork, I set the Defaults for Test::Unit/Shoulda to have the following as the Ruby arguments: "-I. -Itest -S testdrb", so that when I "Run context configuration" it sets up a new configuration and runs my test through spork with no hassle (Assuming the spork server is running :) ).  RubyMine doesn't have Spork support for TestUnit, so not sure if this would be necessary if it did.

However, once in a while I would also like to debug a test, but since the Run and Debug actions share the same configuration, and this default configuration calls testdrb, when I try to debug it also tries to go through testdrb and fails.

I understand the use case. Seems spork+test-unit support in RubyMine will solve the problem related to defaults. In case of RSpec+Spork RubyMine automatically launches debug without spork even if spork support is turned on in run configuration. Please vote and track http://youtrack.jetbrains.net/issue/RUBY-6933

While the above would keep me happy for now, in an ideal world I'd love to be able to debug through spork to make debugging as fast as running, but I don't think this is easy due to the forking action going on.  One would have to make rubymine run testdrb and then connect to the forked process instead of testdrb.  Maybe the "script" that is passed to spork through testdrb could cause rdebug to get loaded in the fork and connect back to the rubymine debugger port...?

Probably we can launch spork server in with attached debugger (just launch testdrb ruby script using RubyMine Debug run confugration) and then ordinary Unit::Test run configuration will force server to stop on breakpoints. You can try.

Right now all I see is "No tests were found" in the left panel, even though they ran just fine in the right panel (understandable given the nature of fork, some kind of result parser needed?)


RubyMine automatically forces Test::Unit framework to use our custom test result formatter which sends test started/finished events to our GUI. In case of spork we need to patch "testrb" environment and pass our custom formatter. "No tests were found" - means that no events from our formatter were received.

0
Comment actions Permalink


I understand the use case. Seems spork+test-unit support in RubyMine will solve the problem related to defaults. In case of RSpec+Spork RubyMine automatically launches debug without spork even if spork support is turned on in run configuration. Please vote and track
http://youtrack.jetbrains.net/issue/RUBY-6933



I'd vote for that bug, but I was the one that filed it :)

Probably we can launch spork server in with attached debugger (just launch testdrb ruby script using RubyMine Debug run confugration) and then ordinary Unit::Test run configuration will force server to stop on breakpoints. You can try.



Ok thanks,  I'l give the debugging a try (Assuming I don't need the integrated spork/tesunit support).  I get some cli usage error when I launch the testdrb script ikn debug, so will have to dig into that a bit.


RubyMine automatically forces Test::Unit framework to use our custom test result formatter which sends test started/finished events to our GUI. In case of spork we need to patch "testrb" environment and pass our custom formatter. "No tests were found" - means that no events from our formatter were received.



So if/when you add spork/testunit support, that would fix this, right?  Thanks,

Matt
0
Comment actions Permalink

I'd vote for that bug, but I was the one that filed it :)

Oops =)

So if/when you add spork/testunit support, that would fix this, right?  Thanks,

Yes, exactly.

0
Comment actions Permalink

Probably we can launch spork server in with attached debugger (just launch testdrb ruby script using RubyMine Debug run confugration) and then ordinary Unit::Test run configuration will force server to stop on breakpoints. You can try.



I didn't realize this before, but it looks like spork works with ruby-debug.  By requiring the spork debug helper after spork, adding ruby-debug to my gemfile, and adding a debugger statement in my code, I was able to step around in the forked sub-process.  Details on usage in the spork codebase:

https://github.com/timcharper/spork/blob/master/features/spork_debugger.feature

Maybe this can help with debugger integration in rubymine  (assuming you add spork/testunit support - 3.1.1 please? :) )

Matt
0
Comment actions Permalink

I've written a spork plugin gem that lets one debug Test::Unit tests from within rubymine

https://github.com/wr0ngway/spork-rdebugide-testunit

Its somewhat of a dirty hack since I don't have control over how rubymine calls rdebug-ide - I basically end up parsing out the rdebug-ide command line args in the spork plugin and starting rdebug-ide to connect back to RubyMine.  However, this acts as a proof of concept, and is probably something RubyMine should clean up and integrate to allow users to debug the stuff they run through spork.

This is how I setup to use it:

Gemfile:


group :test do
  gem "spork", "0.9.0.rc3"
  gem "spork-testunit"
  gem "spork-rdebugide-testunit"
  # these debug gems/versions are provided by rubymine
  # and are needed by spork-rdebugide-testunit
  gem "ruby-debug-ide", "0.4.17.beta3"
  gem "ruby-debug-base19x", "0.11.25"
end


Terminal:



> bundle install
> spork rdebugidetestunit




In RubyMine:



Run -> Edit Configurations -> Defaults -> Test::Unit/Shoulda : change ruby arguments to be "-I. -Itest -S dtestdrb"

For new defaults to take effect, you also need to delete any existing configurations under Run -> Edit Configurations -> Test::Unit/Shoulda


Set your breakpoints, run/debug your Test::Unit tests as for normal ruby processes.


Hope this helps someone else, as it was a real pain to figure out, but worth it!  Any sufficiently large rails project is unmanageable without spork due to the many tens of seconds it can take to load up.  My price for RubyMine devs is that they add spork/Test::Unit support ;)




Matt


0

Please sign in to leave a comment.