JRuby fails to run tests in newly created Rails 3 beta project
--------------------------------------------------------------
Key: JRUBY-4567
URL: http://jira.codehaus.org/browse/JRUBY-4567
Project: JRuby
Issue Type: Bug
Affects Versions: JRuby 1.4
Environment: 0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java
HotSpot(TM) 64-Bit Server VM 1.6.0_17) [x86_64-java] Mac OS X 10.6.2 Intel
Reporter: Cliff Matthews
Assignee: Thomas E Enebo
I created a new Rails 3.0 beta project, used the integration test generator to
create a new test, ran my tests and never saw output saying that my tests ran.
Looking further into it, I found that the Test::Unit after_exit call was
choosing not to run the tests due to "$!". Specifically, I added this code to
the end of my test:
{code}
at_exit do
STDERR.puts "now I've run, $! = #{$!}, Test::Unit.run? = #{Test::Unit.run?}"
end
{code}
and what was printed was:
{noformat}
now I've run, $! = uninitialized constant
ActiveSupport::Testing::SetupAndTeardown::MiniTest, Test::Unit.run? = false
{noformat}
Since Test::Unit won't run a test if $! is non-nil and non-false, my test was
silently not run. This didn't happen when I used MRI (ruby 1.8.7 (2008-08-11
patchlevel 72) [universal-darwin10.0]).
I tracked the problem down to line 10 of
activesupport-3.0.0.beta/lib/active_support/testing/setup_and_teardown.rb,
which is:
{code}
if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions
{code}
Specifically, if I change the first "MiniTest" to "MiniTestX", the error
message will then complain about "MiniTestx" and if I insert "false &&" at the
beginning of the test, so it reads
{code}
if false && defined?(::MiniTestX::Assertions) && TestCase <
::MiniTest::Assertions
{code}
then my $! becomes nil once again and my test is run.
I spent a little time trying to boil this down to a smaller test case, without
success. I imagine that with work I can do so, although I also suspect that
others will be able to reproduce my problem and have a good idea where to
search.
Here's what it looks like (I've added some white space, but left various other
errors in so that it's obvious that I haven't skipped a step):
{noformat}
bash-3.2$ jruby -S rails jruby_test_bug -O -J
create
create README
...
create vendor/plugins
create vendor/plugins/.gitkeep
bash-3.2$ cd jruby_test_bug
bash-3.2$ jruby -S rails generate test_unit:integration foo
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/application.rb:18
warning: `class_eval' should not be aliased
create test/integration/foo_test.rb
bash-3.2$ jruby -S rake test:integration
(in /Users/ctm/j/jruby_test_bug)
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/application.rb:18
warning: `class_eval' should not be aliased
rake aborted!
Don't know how to build task 'db:test:prepare'
(See full trace by running task with --trace)
bash-3.2$ echo 'namespace :db do
namespace :test do
task :prepare do
end
end
end' > lib/tasks/oops.rake
bash-3.2$ jruby -S rake test:integration
(in /Users/ctm/j/jruby_test_bug)
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/application.rb:18
warning: `class_eval' should not be aliased
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/application.rb:18
warning: `class_eval' should not be aliased
/Users/ctm/j/jruby_test_bug/test/test_helper.rb:10: undefined method `fixtures'
for ActiveSupport::TestCase:Class (NoMethodError)
from /Users/ctm/j/jruby_test_bug/test/test_helper.rb:1:in `require'
from ./test/integration/foo_test.rb:1
from ./test/integration/foo_test.rb:5:in `load'
from
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in
`each'
from
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/usr/local/jruby-1.4.0/bin/jruby -I"lib:te...]
(See full trace by running task with --trace)
bash-3.2$ sed -i orig '/fixtures :all/s//# fixtures :all/' test/test_helper.rb
test/integration/foo_test.rb
bash-3.2$ jruby -S rake test:integration
(in /Users/ctm/j/jruby_test_bug)
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/application.rb:18
warning: `class_eval' should not be aliased
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/application.rb:18
warning: `class_eval' should not be aliased
bash-3.2$ echo 'at_exit do
STDERR.puts "now I have run, $! = #{$!}, Test::Unit.run? =
#{Test::Unit.run?}"
end' >> test/integration/foo_test.rb
bash-3.2$ jruby -S rake test:integration
(in /Users/ctm/j/jruby_test_bug)
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/application.rb:18
warning: `class_eval' should not be aliased
/usr/local/jruby-1.4.0/lib/ruby/gems/1.8/gems/railties-3.0.0.beta/lib/rails/application.rb:18
warning: `class_eval' should not be aliased
now I have run, $! = uninitialized constant
ActiveSupport::Testing::SetupAndTeardown::MiniTest, Test::Unit.run? = false
{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email