aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2011-12-21 08:15:36 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2011-12-21 10:04:56 -0700
commit14c89e7285d4e7cd40a542fbc31d9345f60c3aa4 (patch)
treef81c3a4a6ba8e1747aef1e1e24804af84513bebd
parentc1b2642a9eb54a5f83b19d0507306bb58c889ac1 (diff)
downloadrails-14c89e7285d4e7cd40a542fbc31d9345f60c3aa4.tar.gz
rails-14c89e7285d4e7cd40a542fbc31d9345f60c3aa4.tar.bz2
rails-14c89e7285d4e7cd40a542fbc31d9345f60c3aa4.zip
Rails::SubTestTask warns on test failure and moves on. Renamed from TestTaskWithoutDescription.
This makes it easier to add your own tests to the default suite: task test: 'test:acceptance' namespace :test do Rails::SubTestTask.new acceptance: 'test:prepare' do |t| t.libs << 'test' t.pattern = 'test/acceptance/**/*_test.rb' end end Now `rake` runs unit, functional, integration, and acceptance tests.
-rw-r--r--railties/lib/rails/test_unit/testing.rake83
1 files changed, 38 insertions, 45 deletions
diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake
index 52d92cdd96..cf86cf67f2 100644
--- a/railties/lib/rails/test_unit/testing.rake
+++ b/railties/lib/rails/test_unit/testing.rake
@@ -1,32 +1,40 @@
require 'rbconfig'
require 'rake/testtask'
-# Monkey-patch to silence the description from Rake::TestTask to cut down on rake -T noise
-class TestTaskWithoutDescription < Rake::TestTask
- # Create the tasks defined by this task lib.
- def define
- lib_path = @libs.join(File::PATH_SEPARATOR)
- task @name do
- run_code = ''
- RakeFileUtils.verbose(@verbose) do
- run_code =
- case @loader
- when :direct
- "-e 'ARGV.each{|f| load f}'"
- when :testrb
- "-S testrb #{fix}"
- when :rake
- rake_loader
+module Rails
+ # Don't abort when tests fail; move on the next test task.
+ # Silence the default description to cut down on `rake -T` noise.
+ class SubTestTask < Rake::TestTask
+ # Create the tasks defined by this task lib.
+ def define
+ lib_path = @libs.join(File::PATH_SEPARATOR)
+ task @name do
+ run_code = ''
+ RakeFileUtils.verbose(@verbose) do
+ run_code =
+ case @loader
+ when :direct
+ "-e 'ARGV.each{|f| load f}'"
+ when :testrb
+ "-S testrb #{fix}"
+ when :rake
+ rake_loader
+ end
+ @ruby_opts.unshift( "-I\"#{lib_path}\"" )
+ @ruby_opts.unshift( "-w" ) if @warning
+
+ begin
+ ruby @ruby_opts.join(" ") +
+ " \"#{run_code}\" " +
+ file_list.collect { |fn| "\"#{fn}\"" }.join(' ') +
+ " #{option_list}"
+ rescue => error
+ warn "Error running #{@name}: #{error.inspect}"
end
- @ruby_opts.unshift( "-I\"#{lib_path}\"" )
- @ruby_opts.unshift( "-w" ) if @warning
- ruby @ruby_opts.join(" ") +
- " \"#{run_code}\" " +
- file_list.collect { |fn| "\"#{fn}\"" }.join(' ') +
- " #{option_list}"
+ end
end
+ self
end
- self
end
end
@@ -75,22 +83,7 @@ end
task :default => :test
desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)'
-task :test do
- tests_to_run = ENV['TEST'] ? ["test:single"] : %w(test:units test:functionals test:integration)
- errors = tests_to_run.collect do |task|
- begin
- Rake::Task[task].invoke
- nil
- rescue => e
- { :task => task, :exception => e }
- end
- end.compact
-
- if errors.any?
- puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
- abort
- end
-end
+task :test => %w(test:units test:functionals test:integration)
namespace :test do
task :prepare do
@@ -134,33 +127,33 @@ namespace :test do
t.libs << "test"
end
- TestTaskWithoutDescription.new(:units => "test:prepare") do |t|
+ Rails::SubTestTask.new(:units => "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/unit/**/*_test.rb'
end
- TestTaskWithoutDescription.new(:functionals => "test:prepare") do |t|
+ Rails::SubTestTask.new(:functionals => "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/functional/**/*_test.rb'
end
- TestTaskWithoutDescription.new(:integration => "test:prepare") do |t|
+ Rails::SubTestTask.new(:integration => "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/integration/**/*_test.rb'
end
- TestTaskWithoutDescription.new(:benchmark => 'test:prepare') do |t|
+ Rails::SubTestTask.new(:benchmark => 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
t.options = '-- --benchmark'
end
- TestTaskWithoutDescription.new(:profile => 'test:prepare') do |t|
+ Rails::SubTestTask.new(:profile => 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end
- TestTaskWithoutDescription.new(:plugins => :environment) do |t|
+ Rails::SubTestTask.new(:plugins => :environment) do |t|
t.libs << "test"
if ENV['PLUGIN']