Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Update Rake tasks to call `rails test` instead"

This reverts commit b51673f.
  • Loading branch information...
commit 29f973c92c848345a3b8eabe5a6123e68a3df7f9 1 parent 7b295ef
Aaron Patterson tenderlove authored
80 railties/lib/rails/test_unit/testing.rake
View
@@ -1,7 +1,6 @@
require 'rbconfig'
require 'rake/testtask'
require 'rails/test_unit/sub_test_task'
-require 'active_support/deprecation'
TEST_CHANGES_SINCE = Time.now - 600
@@ -48,11 +47,7 @@ task default: :test
desc 'Runs test:units, test:functionals, test:integration together'
task :test do
- if ENV['TEST']
- exec "bundle exec rails test #{ENV['TEST'].inspect}"
- else
- exec 'bundle exec rails test'
- end
+ Rake::Task[ENV['TEST'] ? 'test:single' : 'test:run'].invoke
end
namespace :test do
@@ -61,8 +56,19 @@ namespace :test do
end
task :run do
- ActiveSupport::Deprecation.warn "`rake test:run` is deprecated. Please use `rails test`."
- exec 'bundle exec rails test'
+ errors = %w(test:units test:functionals test:integration).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
# Inspired by: http://ngauthier.com/2012/02/quick-tests-with-bash.html
@@ -77,13 +83,7 @@ namespace :test do
task :db => %w[db:test:prepare test:all]
end
- # Display deprecation message
- task :deprecated do
- task_name = ARGV.first
- ActiveSupport::Deprecation.warn "`rake #{ARGV.first}` is deprecated with no replacement."
- end
-
- Rake::TestTask.new(recent: ["test:deprecated", "test:prepare"]) do |t|
+ 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/models', since) +
@@ -94,9 +94,9 @@ namespace :test do
t.libs << 'test'
t.test_files = touched.uniq
end
- Rake::Task['test:recent'].comment = "Deprecated; Test recent changes"
+ Rake::Task['test:recent'].comment = "Test recent changes"
- Rake::TestTask.new(uncommitted: ["test:deprecated", "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` }.split.map { |path| path.chomp[7 .. -1] }
@@ -118,20 +118,44 @@ namespace :test do
t.libs << 'test'
end
- Rake::Task['test:uncommitted'].comment = "Deprecated; Test changes since last checkin (only Subversion and Git)"
+ Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
- desc "Deprecated; Please use `rails test \"#{ENV['TEST']}\"`"
- task :single do
- ActiveSupport::Deprecation.warn "`rake test:single` is deprecated. Please use `rails test \"#{ENV['TEST']}\"`."
- exec "bundle exec rails test #{test_suit_name}"
+ Rake::TestTask.new(single: "test:prepare") do |t|
+ t.libs << "test"
end
- [:models, :helpers, :units, :controllers, :functionals, :integration].each do |test_suit_name|
- desc "Deprecated; Please use `rails test #{test_suit_name}`"
- task test_suit_name do
- ActiveSupport::Deprecation.warn "`rake test:#{test_suit_name}` is deprecated. Please use `rails test #{test_suit_name}`."
+ Rails::SubTestTask.new(models: "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/models/**/*_test.rb'
+ end
- exec "bundle exec rails test #{test_suit_name}"
- end
+ Rails::SubTestTask.new(helpers: "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/helpers/**/*_test.rb'
+ end
+
+ Rails::SubTestTask.new(units: "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/{models,helpers,unit}/**/*_test.rb'
+ end
+
+ Rails::SubTestTask.new(controllers: "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/controllers/**/*_test.rb'
+ end
+
+ Rails::SubTestTask.new(mailers: "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/mailers/**/*_test.rb'
+ end
+
+ Rails::SubTestTask.new(functionals: "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/{controllers,mailers,functional}/**/*_test.rb'
+ end
+
+ Rails::SubTestTask.new(integration: "test:prepare") do |t|
+ t.libs << "test"
+ t.pattern = 'test/integration/**/*_test.rb'
end
end
23 railties/test/application/rake_test.rb
View
@@ -91,9 +91,19 @@ def test_rake_test_error_output
raise 'models'
RUBY
+ app_file "test/controllers/one_controller_test.rb", <<-RUBY
+ raise 'controllers'
+ RUBY
+
+ app_file "test/integration/one_integration_test.rb", <<-RUBY
+ raise 'integration'
+ RUBY
+
silence_stderr do
output = Dir.chdir(app_path) { `rake test 2>&1` }
assert_match 'models', output
+ assert_match 'controllers', output
+ assert_match 'integration', output
end
end
@@ -125,19 +135,6 @@ def test_rake_test_uncommitted_fails_with_no_scm
end
end
- def test_rake_test_deprecation_messages
- Dir.chdir(app_path){ `rails generate scaffold user name:string` }
- Dir.chdir(app_path){ `rake db:migrate` }
-
- %w(run recent uncommitted models helpers units controllers functionals integration).each do |test_suit_name|
- output = Dir.chdir(app_path) { `rake test:#{test_suit_name} 2>&1` }
- assert_match /DEPRECATION WARNING: `rake test:#{test_suit_name}` is deprecated/, output
- end
-
- assert_match /DEPRECATION WARNING: `rake test:single` is deprecated/,
- Dir.chdir(app_path) { `rake test:single TEST=test/models/user_test.rb 2>&1` }
- end
-
def test_rake_routes_calls_the_route_inspector
app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do
Please sign in to comment.
Something went wrong with that request. Please try again.