Debugging unit tests fails with "uninitialized constant Test::Unit::AutoRunner::RUNNERS"

I'm trying to debug a simple unit-test which looks like this:

require 'test/unit'

class X < Test::Unit::TestCase

def test_foo
fail("nope")
end
end

When trying to debug this, I get the following exception:

/usr/bin/ruby -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /var/lib/gems/2.3.0/gems/ruby-debug-ide-0.6.1.beta2/bin/rdebug-ide --disable-int-handler --evaluation-timeout 10 --rubymine-protocol-extensions --port 38211 --host 0.0.0.0 --dispatcher-port 40438 -- /home/jesperes/dev/ewarm-ide-core-trunk/core/ide/Services/src-ruby/cspyserver_test.rb
Testing started at 14:35 ...
Fast Debugger (ruby-debug-ide 0.6.1.beta2, debase 0.2.2.beta8, file filtering is supported) listens on 0.0.0.0:38211
Uncaught exception: uninitialized constant Test::Unit::AutoRunner::RUNNERS
/home/jesperes/RubyMine-2016.2.5/rb/testing/patch/testunit/test/unit/autorunner.rb:30:in `<class:AutoRunner>'
/home/jesperes/RubyMine-2016.2.5/rb/testing/patch/testunit/test/unit/autorunner.rb:29:in `<module:Unit>'
/home/jesperes/RubyMine-2016.2.5/rb/testing/patch/testunit/test/unit/autorunner.rb:28:in `<module:Test>'
/home/jesperes/RubyMine-2016.2.5/rb/testing/patch/testunit/test/unit/autorunner.rb:27:in `<top (required)>'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/vendor_ruby/test/unit.rb:2:in `<top (required)>'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/jesperes/dev/ewarm-ide-core-trunk/core/ide/Services/src-ruby/cspyserver_test.rb:1:in `<top (required)>'

Process finished with exit code 0

 

1
2 comments

Hello, Jesper,

it looks similar to https://youtrack.jetbrains.com/issue/RUBY-18752.

We're working on it, please follow/vote. Sorry for inconvenience.

0
Avatar
Permanently deleted user

Printing $LOAD_PATH from inside "<...>rb/testing/patch/testunit/test/unit/autorunner.rb" shows that the problem is that "<...>/rb/testing/patch/testunit" which was meant to patch files under "<gem home>/test-unit-3.1.3/lib" (most specifically "<gem home>/test-unit-3.1.3/lib/test/unit/autorunner.rb") actually appears in the LOAD_PATH *before* "<gem home>/test-unit-3.1.3/lib", and thus completely shadows it.

I worked around this by adding an explicit --require to the "Runner Options" in the Run Configuration: "--require <gem home>/test-unit-3.1.3/lib/test/unit/autorunner". You can run e.g. "bundle show test-unit" (if using Bundler) or "gem which test-unit" to figure out where test-unit gem home is, for me the actual runner option string from Run Configuration is "--require /home/deploy/.rvm/gems/ruby-2.2.5/gems/test-unit-3.1.3/lib/test/unit/autorunner".

 

0

Please sign in to leave a comment.