summaryrefslogtreecommitdiff
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
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
-rw-r--r--test/lib/test/unit.rb13
-rw-r--r--test/lib/test/unit/parallel.rb18
-rw-r--r--test/testunit/test_parallel.rb14
3 files changed, 40 insertions, 5 deletions
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb
index 981c1c1..9532584 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 1e12d18..c1b6094 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
diff --git a/test/testunit/test_parallel.rb b/test/testunit/test_parallel.rb
index 3d85f9c..35901df 100644
--- a/test/testunit/test_parallel.rb
+++ b/test/testunit/test_parallel.rb
@@ -43,6 +43,7 @@ module TestParallel
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_first.rb test"
assert_match(/^okay/,@worker_out.gets)
+ assert_match(/^record/,@worker_out.gets)
assert_match(/^p/,@worker_out.gets)
assert_match(/^done/,@worker_out.gets)
assert_match(/^ready/,@worker_out.gets)
@@ -54,8 +55,10 @@ module TestParallel
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_second.rb test"
assert_match(/^okay/,@worker_out.gets)
+ assert_match(/^record/,@worker_out.gets)
assert_match(/^p/,@worker_out.gets)
assert_match(/^done/,@worker_out.gets)
+ assert_match(/^record/,@worker_out.gets)
assert_match(/^p/,@worker_out.gets)
assert_match(/^done/,@worker_out.gets)
assert_match(/^ready/,@worker_out.gets)
@@ -67,13 +70,16 @@ module TestParallel
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_first.rb test"
assert_match(/^okay/,@worker_out.gets)
+ assert_match(/^record/,@worker_out.gets)
assert_match(/^p/,@worker_out.gets)
assert_match(/^done/,@worker_out.gets)
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_second.rb test"
assert_match(/^okay/,@worker_out.gets)
+ assert_match(/^record/,@worker_out.gets)
assert_match(/^p/,@worker_out.gets)
assert_match(/^done/,@worker_out.gets)
+ assert_match(/^record/,@worker_out.gets)
assert_match(/^p/,@worker_out.gets)
assert_match(/^done/,@worker_out.gets)
assert_match(/^ready/,@worker_out.gets)
@@ -93,11 +99,9 @@ module TestParallel
def test_done
Timeout.timeout(10) do
@worker_in.puts "run #{TESTS}/ptest_forth.rb test"
- 7.times { @worker_out.gets }
- buf = @worker_out.gets
- assert_match(/^done (.+?)$/, buf)
-
- /^done (.+?)$/ =~ buf
+ while buf = @worker_out.gets
+ break if /^done (.+?)$/ =~ buf
+ end
result = Marshal.load($1.chomp.unpack("m")[0])