diff options
Diffstat (limited to 'railties/lib/rails/test_unit')
-rw-r--r-- | railties/lib/rails/test_unit/minitest_plugin.rb | 15 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/runner.rb | 19 |
2 files changed, 19 insertions, 15 deletions
diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb new file mode 100644 index 0000000000..149aad372c --- /dev/null +++ b/railties/lib/rails/test_unit/minitest_plugin.rb @@ -0,0 +1,15 @@ +require "minitest" +require "rails/test_unit/reporter" + +def Minitest.plugin_rails_init(options) + self.reporter << Rails::TestUnitReporter.new(options[:io], options) + if $rails_test_runner && (method = $rails_test_runner.find_method) + options[:filter] = method + end + + if ENV["BACKTRACE"].nil? && !($rails_test_runner && $rails_test_runner.show_backtrace?) + Minitest.backtrace_filter = Rails.backtrace_cleaner + end +end +Minitest.extensions << 'rails' + diff --git a/railties/lib/rails/test_unit/runner.rb b/railties/lib/rails/test_unit/runner.rb index 31ce94a503..c777091b57 100644 --- a/railties/lib/rails/test_unit/runner.rb +++ b/railties/lib/rails/test_unit/runner.rb @@ -2,7 +2,6 @@ require "ostruct" require "optparse" require "rake/file_list" require "method_source" -require "rails/test_unit/reporter" module Rails class TestRunner @@ -58,17 +57,7 @@ module Rails end def run - enable_backtrace if @options[:backtrace] - $rails_test_runner = self - def Minitest.plugin_rails_init(options) - self.reporter << Rails::TestUnitReporter.new(options[:io], options) - if method = $rails_test_runner.find_method - options[:filter] = method - end - end - Minitest.extensions << 'rails' - run_tests end @@ -82,6 +71,10 @@ module Rails method[1] if method end + def show_backtrace? + @options[:backtrace] + end + private def run_tests test_files.to_a.each do |file| @@ -102,10 +95,6 @@ module Rails Rake::FileList[pattern] end - def enable_backtrace - ENV["BACKTRACE"] = "1" - end - def test_methods methods_map = [] suites = Minitest::Runnable.runnables.shuffle |