From 09c70a0c03aa755a66dc94ebb2b98b283c7137c9 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 15 Jun 2008 16:21:32 -0700 Subject: [PATCH] Use test/performance/test_helper to do test setup then boost log level and turn on caching --- railties/helpers/performance_test.rb | 5 +---- railties/helpers/performance_test_helper.rb | 6 ++++++ .../generators/applications/app/app_generator.rb | 1 + railties/lib/tasks/testing.rake | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 railties/helpers/performance_test_helper.rb diff --git a/railties/helpers/performance_test.rb b/railties/helpers/performance_test.rb index d39f639305d9e..7c89816570e4b 100644 --- a/railties/helpers/performance_test.rb +++ b/railties/helpers/performance_test.rb @@ -1,7 +1,4 @@ -ENV['RAILS_ENV'] ||= 'test' -require "#{File.dirname(__FILE__)}/../../config/environment" -require 'test/unit' -require 'action_controller/performance_test' +require 'performance/test_helper' # Profiling results for each test method are written to tmp/performance. class BrowsingTest < ActionController::PerformanceTest diff --git a/railties/helpers/performance_test_helper.rb b/railties/helpers/performance_test_helper.rb new file mode 100644 index 0000000000000..3c4c7fb740267 --- /dev/null +++ b/railties/helpers/performance_test_helper.rb @@ -0,0 +1,6 @@ +require 'test_helper' +require 'action_controller/performance_test' + +ActionController::Base.perform_caching = true +ActiveSupport::Dependencies.mechanism = :require +Rails.logger.level = ActiveSupport::BufferedLogger::INFO diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index d31ab5bb495c7..80e8eabfd31a5 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -51,6 +51,7 @@ def manifest m.template "helpers/application.rb", "app/controllers/application.rb", :assigns => { :app_name => @app_name, :app_secret => md5.hexdigest } m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb" m.template "helpers/test_helper.rb", "test/test_helper.rb" + m.template "helpers/performance_test_helper.rb", "test/performance/test_helper.rb" m.template "helpers/performance_test.rb", "test/performance/browsing_test.rb" # database.yml and routes.rb diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake index 2cadcd55fa135..c8ba6eed94a18 100644 --- a/railties/lib/tasks/testing.rake +++ b/railties/lib/tasks/testing.rake @@ -103,7 +103,7 @@ namespace :test do end Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" - Rake::TestTask.new(:benchmark) do |t| + Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.verbose = true @@ -111,7 +111,7 @@ namespace :test do end Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests' - Rake::TestTask.new(:profile) do |t| + Rake::TestTask.new(:profile => 'db:test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.verbose = true