require self made gem in jruby fails after update

2019-03-05 03:00发布

问题:

I used jruby-1.7.0 and testing frame work Test::Unit::TestCase. Now I have updated some gems which caused me to use MiniTest::Test for testing, so I also upgraded to jruby-1.7.13. I have a rake task too which builds my gems with java *.class files instead of ruby *.rb files. Now many things dont work any more like 'rake test', or require "my_gem_xyz" from irb, getting errors like load error and ArrayIndexOutOfBoudsException. I have rvm installed to switch between rubies.

How can I use *.class files in my self made gems like it worked before under jruby-1.7.0? (If I include the *.rb files in the gem it seems to work ok)

Some time ago I tried with jruby-1.7.4 but that also failed with similar reasons (at that time I still used Test::Unit::TestCase, so the test frame work is not the problem)

Any ideas?

Frank

回答1:

I found a surprising solution to the problem. I had compiled the *.rb classes with my jruby version 1.7.0's jrubyc. This caused the tests to fail with the load error. I had to compile all ruby classes with the jrubyc version 1.7.13 where I also build the gems.

update:

'rake test' still does not work comming up with errors like Mocha::ExpectationError: unexpected invocation: ...

what works is to use test options specifiying test file and test name (also with reg.exp.) like

rake test TEST=test/test_bla_bla.rb TESTOPTS="--name=/test_should_read/ -v"

I have the feeling the randomization with the seed parameter causes the problem. How can I influence the seed parameter?

update:

It looks like if there are too many tests in the test suite, MiniTest cannot handle this. In some cases I could run about 10 tests in some up to 35, using the TESTOPTS switch. I always fail if I run all tests in my test library with 'rake test'. This looks like a bug to me. Is there anybody who can help?