From 253bb6b9260938ed673e2c0059d729cffff4a523 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 4 Jun 2011 23:19:17 +0100 Subject: Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases. --- activerecord/Rakefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'activerecord/Rakefile') diff --git a/activerecord/Rakefile b/activerecord/Rakefile index 346c7e8142..d5863ab14d 100755 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -43,26 +43,24 @@ end %w( mysql mysql2 postgresql sqlite3 sqlite3_mem firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter| Rake::TestTask.new("test_#{adapter}") { |t| - connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}" adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/] - t.libs << "test" << connection_path t.test_files = (Dir.glob( "test/cases/**/*_test.rb" ).reject { |x| x =~ /\/adapters\// } + Dir.glob("test/cases/adapters/#{adapter_short}/**/*_test.rb")).sort t.verbose = true t.warning = true + t.ruby_opts = ["-r#{File.expand_path('../', __FILE__)}/test/connections/#{adapter}"] } task "isolated_test_#{adapter}" do - connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}" adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/] - puts [adapter, adapter_short, connection_path].inspect + puts [adapter, adapter_short].inspect ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) (Dir["test/cases/**/*_test.rb"].reject { |x| x =~ /\/adapters\// } + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file| - sh(ruby, "-Ilib:test:#{connection_path}", file) + sh(ruby, "-Itest", "-r#{File.expand_path('../', __FILE__)}/test/connections/#{adapter}", file) end or raise "Failures" end -- cgit v1.2.3