diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-04-09 00:40:48 -0300 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2010-04-09 16:03:27 +1200 |
commit | 808847792c84e6d21ed7a2fb24b7e711b0007171 (patch) | |
tree | 0a872f4a6f59bf5159deddbc6d8b5be3c1954af6 | |
parent | 4691c696b0cda985c5d868312555cd538328a99c (diff) | |
download | rails-808847792c84e6d21ed7a2fb24b7e711b0007171.tar.gz rails-808847792c84e6d21ed7a2fb24b7e711b0007171.tar.bz2 rails-808847792c84e6d21ed7a2fb24b7e711b0007171.zip |
db:test:prepare for tasks only if AR is loaded
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 2 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/testing.rake | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 0229793a9a..2b53afc68b 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -446,6 +446,8 @@ namespace :db do end end +task 'test:prepare' => 'db:test:prepare' + def drop_database(config) case config['adapter'] when 'mysql' diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 57857fb911..23b8f92abd 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -52,7 +52,11 @@ task :test do end namespace :test do - Rake::TestTask.new(:recent => "db:test:prepare") do |t| + task :prepare do + # Placeholder task for other Railtie and plugins to enhance. See Active Record for an example. + end + + Rake::TestTask.new(:recent => "test:prepare") do |t| since = TEST_CHANGES_SINCE touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } + recent_tests('app/models/**/*.rb', 'test/unit', since) + @@ -63,7 +67,7 @@ namespace :test do end Rake::Task['test:recent'].comment = "Test recent changes" - Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t| + Rake::TestTask.new(:uncommitted => "test:prepare") do |t| def t.file_list if File.directory?(".svn") changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] } @@ -86,32 +90,32 @@ namespace :test do end Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)" - Rake::TestTask.new(:units => "db:test:prepare") do |t| + Rake::TestTask.new(:units => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/unit/**/*_test.rb' end Rake::Task['test:units'].comment = "Run the unit tests in test/unit" - Rake::TestTask.new(:functionals => "db:test:prepare") do |t| + Rake::TestTask.new(:functionals => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/functional/**/*_test.rb' end Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional" - Rake::TestTask.new(:integration => "db:test:prepare") do |t| + Rake::TestTask.new(:integration => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/integration/**/*_test.rb' end Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" - Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t| + Rake::TestTask.new(:benchmark => 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.options = '-- --benchmark' end Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests' - Rake::TestTask.new(:profile => 'db:test:prepare') do |t| + Rake::TestTask.new(:profile => 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' end |