* 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
This commit is contained in:
nobu 2017-02-07 03:55:47 +00:00
Родитель 10c51ff5ce
Коммит 406c5252a2
3 изменённых файлов: 40 добавлений и 5 удалений

Просмотреть файл

@ -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]

Просмотреть файл

@ -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

Просмотреть файл

@ -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])