From 0bc1e4f990c379f5d2bb8a96526ea2562b7de16c Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Wed, 15 Aug 2012 17:11:39 +0900 Subject: [PATCH] Fix parallel test --no-retry option With --no-retry option, test-all with exceptions shows additional results "E". So we don't push "E" of `puke` to `report`. This also fixes broken result format. If a test fails with Exception while test-all with -j option, test-all doesn't complete. Marshal.load fails because subclass of Exception is not required. Instead we use fake Exception object. --- lib/test/unit.rb | 24 ++++++++++++++++++++---- lib/test/unit/parallel.rb | 6 ++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/test/unit.rb b/lib/test/unit.rb index a0902ac..de31b26 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -616,15 +616,20 @@ module Test _run_suites(suites, type) end end + unless @options[:retry] + del_status_line or puts + end unless rep.empty? rep.each do |r| r[:report].each do |f| - report.push(puke(*f)) if f + puke(*f) if f end end - @errors += rep.map{|x| x[:result][0] }.inject(:+) - @failures += rep.map{|x| x[:result][1] }.inject(:+) - @skips += rep.map{|x| x[:result][2] }.inject(:+) + if @options[:retry] + @errors += rep.map{|x| x[:result][0] }.inject(:+) + @failures += rep.map{|x| x[:result][1] }.inject(:+) + @skips += rep.map{|x| x[:result][2] }.inject(:+) + end end unless @warnings.empty? warn "" @@ -824,6 +829,17 @@ module Test new(*args).run end end + + class ProxyException < Exception + def initialize(e) + @class = e.class.name + @message = e.message + @backtrace = e.backtrace + end + + # these methods are used in MiniTest::Unit#puke + attr_accessor :class, :message, :backtrace + end end end diff --git a/lib/test/unit/parallel.rb b/lib/test/unit/parallel.rb index 32f1538..428e47b 100644 --- a/lib/test/unit/parallel.rb +++ b/lib/test/unit/parallel.rb @@ -155,6 +155,12 @@ module Test end def puke(klass, meth, e) + if !e.is_a?(MiniTest::Assertion) && e.is_a?(Exception) + # Create a fake Exception to avoid Marshal.load + # of Exception subclass failing. + e = ProxyException.new(e) + end + @partial_report << [klass.name, meth, e] super end -- 1.7.9.5