extending AR tests to run in JRuby and jdbc

I've got a patch to the AR tests that support running them in JRuby. Right now the patch only works for mysql.

A big part of the reason I'm working on this is to make it easier to test JRuby itself. Charlie Nutter just fixed yesterday JRuby regression that caused these tests to crash yesterday. If I can make it easier to run these tests in JRuby we'll find and fix these problems faster.

Here's an example of a problem in JRuby I found:

   http://jira.codehaus.org/browse/JRUBY-3270

The problem was related to hpricot using a deprecated and then deleted JRuby method that was part of it's implementation of fast_xs. AS uses fast_xs if it is present ...

   http://jira.codehaus.org/browse/JRUBY-3272

I run the AR mysql jdbc tests like this:

   $ jruby -S rake test_jdbcmysql

I've got the patch up here and a listing of what errors are occurring now:

   http://pastie.org/349823

Is anybody else working on something like this.

I was planning to implement the same pattern for other d adapters available via jdbc and then submit a patch to rails.

Is this something the core team would be interested in seeing in the codebase?

I'm not a fan of the platform/implementation conditions. When I did
the SQL Server adapter, I found it very easy to use ruby to coerce the
tests that I needed to. See the links below and you can see how I did
this with a simple method_added hook. This leaves core to do what they
want and focus on corey things and we can use ruby to do what we need
to :slight_smile:

http://github.com/rails-sqlserver/2000-2005-adapter/tree/master
http://github.com/rails-sqlserver/2000-2005-adapter/tree/master/test/cases/sqlserver_helper.rb#L41

- Ken

I'm not a fan of the platform/implementation conditions. When I did the SQL Server adapter, I found it very easy to use ruby to coerce the tests that I needed to. See the links below and you can see how I did this with a simple method_added hook. This leaves core to do what they want and focus on corey things and we can use ruby to do what we need to :slight_smile:

http://github.com/rails-sqlserver/2000-2005-adapter/tree/master
http://github.com/rails-sqlserver/2000-2005-adapter/tree/master/test/cases/sqlserver_helper.rb#L41

Thanks for the comments Ken,

I like the fact that your implementation doesn't touch the rails code.

I don't like that it needs to be in a plugin relationship to rails.

Do you think the same result could be done in a gem install?

I don't have an sqlserver to test your code on but tell me if I've got this right:

Here's how to run the all the Ar tests for sqlsever:

   cd activerecord
   rake test_sqlserver

This runs all the AR tests on the sqlserver server ... except where an original test like this:

   migration_test.rb

has a matching test in your test/cases dir with the adapter name suffixed on the name of the test:

   migration_test_sqlserver.rb

You have 16 test files in your cases dir -- it looks like most of them reflect tests in the AR test/cases dir -- except for:

   aaaa_create_tables_test_sqlserver.rb

which has one extra 'a' compared to the AR test:

   aaa_create_tables_test.rb

This mean you need to track functional changes in the AR tests and port them over to your test suite.