Module: ActiveSupport::Testing::Performance::ForClassicTestUnit

Defined in:
activesupport/lib/active_support/testing/performance.rb

Instance Method Summary collapse

Instance Method Details

#run(result) {|self.class::STARTED, name| ... } ⇒ Object

Yields:

  • (self.class::STARTED, name)


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'activesupport/lib/active_support/testing/performance.rb', line 81

def run(result)
  return if method_name =~ /^default_test$/

  yield(self.class::STARTED, name)
  @_result = result

  run_warmup
  if full_profile_options && metrics = full_profile_options[:metrics]
    metrics.each do |metric_name|
      if klass = Metrics[metric_name.to_sym]
        run_profile(klass.new)
        result.add_run
      else
        puts '%20s: unsupported' % metric_name
      end
    end
  end

  yield(self.class::FINISHED, name)
end

#run_test(metric, mode) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'activesupport/lib/active_support/testing/performance.rb', line 102

def run_test(metric, mode)
  run_callbacks :setup
  setup
  metric.send(mode) { __send__ @method_name }
rescue ::Test::Unit::AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue StandardError, ScriptError => e
  add_error(e)
ensure
  begin
    teardown
    run_callbacks :teardown, :enumerator => :reverse_each
  rescue ::Test::Unit::AssertionFailedError => e
    add_failure(e.message, e.backtrace)
  rescue StandardError, ScriptError => e
    add_error(e)
  end
end