summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-07 03:55:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-07 03:55:47 +0000
commit406c5252a2037ae78c199e12578bee0233bff2d3 (patch)
tree9eac8e615cd69da341284b60b19daa59d67a2bbb /test/lib
parent10c51ff5ce07c4c0bf72bdcfe65cc222a83e9369 (diff)
test/unit: record in parallel
* test/lib/test/unit.rb (Test::Unit::Parallel#deal): deal with record. * test/lib/test/unit/parallel.rb (Test::Unit::Worker#record): report test records to the master. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/test/unit.rb13
-rw-r--r--test/lib/test/unit/parallel.rb18
2 files changed, 31 insertions, 0 deletions
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb
index 981c1c1f2f..9532584eed 100644
--- a/test/lib/test/unit.rb
+++ b/test/lib/test/unit.rb
@@ -372,6 +372,11 @@ module Test
end
end
+ FakeClass = Struct.new(:name)
+ def fake_class(name)
+ (@fake_classes ||= {})[name] ||= FakeClass.new(name)
+ end
+
def deal(io, type, result, rep, shutting_down = false)
worker = @workers_hash[io]
cmd = worker.read
@@ -409,6 +414,14 @@ module Test
$:.push(*r[4]).uniq!
jobs_status(worker) if @options[:job_status] == :replace
return true
+ when /^record (.+?)$/
+ begin
+ r = Marshal.load($1.unpack("m")[0])
+ rescue => e
+ print "unknown record: #{e.message} #{$1.unpack("m")[0].dump}"
+ return true
+ end
+ record(fake_class(r[0]), *r[1..-1])
when /^p (.+?)$/
del_jobs_status
print $1.unpack("m")[0]
diff --git a/test/lib/test/unit/parallel.rb b/test/lib/test/unit/parallel.rb
index 1e12d18457..c1b6094b8c 100644
--- a/test/lib/test/unit/parallel.rb
+++ b/test/lib/test/unit/parallel.rb
@@ -165,6 +165,24 @@ module Test
@partial_report << [klass.name, meth, e.is_a?(MiniTest::Assertion) ? e : ProxyError.new(e)]
super
end
+
+ def record(suite, method, assertions, time, error) # :nodoc:
+ case error
+ when nil
+ when MiniTest::Assertion, MiniTest::Skip
+ case error.cause
+ when nil, MiniTest::Assertion, MiniTest::Skip
+ else
+ bt = error.backtrace
+ error = error.class.new(error.message)
+ error.set_backtrace(bt)
+ end
+ else
+ error = ProxyError.new(error)
+ end
+ _report "record", Marshal.dump([suite.name, method, assertions, time, error])
+ super
+ end
end
end
end