2005-09-03 11:13:06 -04:00
|
|
|
TEST_CHANGES_SINCE = Time.now - 600
|
|
|
|
|
|
|
|
# Look up tests for recently modified sources.
|
|
|
|
def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
|
|
|
|
FileList[source_pattern].map do |path|
|
|
|
|
if File.mtime(path) > touched_since
|
|
|
|
test = "#{test_path}/#{File.basename(path, '.rb')}_test.rb"
|
|
|
|
test if File.exists?(test)
|
|
|
|
end
|
|
|
|
end.compact
|
|
|
|
end
|
|
|
|
|
2005-10-13 16:55:05 -04:00
|
|
|
desc 'Test recent changes'
|
2005-10-13 00:12:32 -04:00
|
|
|
Rake::TestTask.new(:recent => [ :prepare_test_database ]) do |t|
|
2005-09-03 11:13:06 -04:00
|
|
|
since = TEST_CHANGES_SINCE
|
|
|
|
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
|
|
|
|
recent_tests('app/models/*.rb', 'test/unit', since) +
|
|
|
|
recent_tests('app/controllers/*.rb', 'test/functional', since)
|
|
|
|
|
|
|
|
t.libs << 'test'
|
|
|
|
t.verbose = true
|
|
|
|
t.test_files = touched.uniq
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Run the unit tests in test/unit"
|
2005-10-13 16:55:05 -04:00
|
|
|
Rake::TestTask.new(:test_units => [ :prepare_test_database ]) do |t|
|
2005-09-03 11:13:06 -04:00
|
|
|
t.libs << "test"
|
|
|
|
t.pattern = 'test/unit/**/*_test.rb'
|
|
|
|
t.verbose = true
|
2005-10-13 16:55:05 -04:00
|
|
|
end
|
2005-09-03 11:13:06 -04:00
|
|
|
|
|
|
|
desc "Run the functional tests in test/functional"
|
2005-10-13 16:55:05 -04:00
|
|
|
Rake::TestTask.new(:test_functional => [ :prepare_test_database ]) do |t|
|
2005-09-03 11:13:06 -04:00
|
|
|
t.libs << "test"
|
|
|
|
t.pattern = 'test/functional/**/*_test.rb'
|
2005-10-28 15:52:28 -04:00
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)"
|
2005-10-28 16:28:09 -04:00
|
|
|
Rake::TestTask.new(:test_plugins => :environment) do |t|
|
2005-10-28 15:52:28 -04:00
|
|
|
t.libs << "test"
|
|
|
|
|
|
|
|
if ENV['PLUGIN']
|
2005-10-28 16:28:09 -04:00
|
|
|
t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb"
|
2005-10-28 15:52:28 -04:00
|
|
|
else
|
2005-10-28 16:28:09 -04:00
|
|
|
t.pattern = 'vendor/plugins/**/test/**/*_test.rb'
|
2005-10-28 15:52:28 -04:00
|
|
|
end
|
|
|
|
|
2005-09-03 11:13:06 -04:00
|
|
|
t.verbose = true
|
2005-10-28 16:28:09 -04:00
|
|
|
end
|