Permalink
Browse files

Merge pull request #9173 from senny/backport_perftest_fix

Backport rails/rails-perftest#2 to fix rake test:benchmark
  • Loading branch information...
2 parents 63d4894 + b47f8d0 commit 0a55bd7c6bdc4c3022cec858e341f7561ec8554b @senny senny committed Jun 27, 2013
@@ -23,7 +23,7 @@ module Performance
# each implementation should define metrics and freeze the defaults
DEFAULTS =
- if ARGV.include?('--benchmark') # HAX for rake test
+ if ENV["BENCHMARK_TESTS"]
{ :runs => 4,
:output => 'tmp/performance',
:benchmark => true }
@@ -6,7 +6,7 @@ module ActiveSupport
module Testing
module Performance
DEFAULTS.merge!(
- if ARGV.include?('--benchmark')
+ if ENV["BENCHMARK_TESTS"]
{:metrics => [:wall_time, :user_time, :memory, :gc_runs, :gc_time]}
else
{ :metrics => [:wall_time],
@@ -4,7 +4,7 @@ module ActiveSupport
module Testing
module Performance
DEFAULTS.merge!(
- if ARGV.include?('--benchmark')
+ if ENV["BENCHMARK_TESTS"]
{:metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time]}
else
{ :metrics => [:wall_time],
@@ -9,7 +9,7 @@ module ActiveSupport
module Testing
module Performance
DEFAULTS.merge!(
- if ARGV.include?('--benchmark')
+ if ENV["BENCHMARK_TESTS"]
{ :metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time] }
else
{ :min_percent => 0.01,
View
@@ -1,5 +1,11 @@
## unreleased ##
+* Fix bugs that crashed `rake test:benchmark`, `rails profiler` and
+ `rails benchmarker`.
+ Fixes #4938.
+
+ *Yves Senn*
+
* Add support for runner hook.
Backport #7695.
@@ -21,6 +27,11 @@
* No changes.
+* Fix launching performance tests through rake `test:benchmark`.
+ Fixes #4938.
+ Backport rails/rails-perftest#2.
+
+ *Dmitry Vorotilin + Yves Senn*
## Rails 3.2.11 (Jan 8, 2013) ##
@@ -2,9 +2,8 @@
require 'rails/test_help'
require 'rails/performance_test_help'
-ARGV.push('--benchmark') # HAX
+ENV["BENCHMARK_TESTS"] = '1'
require 'active_support/testing/performance'
-ARGV.pop
def options
options = {}
@@ -31,4 +30,5 @@ def test_#{expression.parameterize('_')}
end
RUBY
end
+ ARGV.clear
end
@@ -29,4 +29,5 @@ def test_#{expression.parameterize('_')}
end
RUBY
end
+ ARGV.clear
end
@@ -123,10 +123,13 @@ namespace :test do
t.pattern = 'test/integration/**/*_test.rb'
end
- Rails::SubTestTask.new(:benchmark => 'test:prepare') do |t|
+ task 'test:benchmark_mode' do
+ ENV["BENCHMARK_TESTS"] = '1'
+ end
+
+ Rails::SubTestTask.new(:benchmark => ['test:prepare', 'test:benchmark_mode']) do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
- t.options = '-- --benchmark'
end
Rails::SubTestTask.new(:profile => 'test:prepare') do |t|

0 comments on commit 0a55bd7

Please sign in to comment.