1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/test/unit/parallel.rb: Never Ignore SIGINT. When received

Interrupt, immediately puts result and exit. [ruby-dev:43571]

* lib/test/unit.rb: When received Interrupt, wait results from workers
and correct them. [ruby-dev:43571]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
sorah 2011-05-23 00:10:49 +00:00
parent 1e13786700
commit 6dc0488148
3 changed files with 44 additions and 6 deletions

View file

@ -1,3 +1,11 @@
Mon May 23 09:03:52 2011 Shota Fukumori <sorah@tubusu.net>
* lib/test/unit/parallel.rb: Never Ignore SIGINT. When received
Interrupt, immediately puts result and exit. [ruby-dev:43571]
* lib/test/unit.rb: When received Interrupt, wait results from workers
and correct them. [ruby-dev:43571]
Mon May 23 09:08:07 2011 Eric Hodel <drbrain@segment7.net>
* lib/mathn.rb: Improve documentation. Patch by Sandor Szucs.

View file

@ -445,7 +445,7 @@ module Test
jobs_status
when /^done (.+?)$/
r = Marshal.load($1.unpack("m")[0])
result << r[0..1]
result << r[0..1] unless r[0..1] == [nil,nil]
rep << {file: worker.real_file,
report: r[2], result: r[3], testcase: r[5]}
$:.push(*r[4]).uniq!
@ -474,6 +474,24 @@ module Test
shutting_down = true
watchdog.kill if watchdog
if @interrupt
@ios.select!{|x| @workers_hash[x].status == :running }
while !@ios.empty? && (__io = IO.select(@ios,[],[],10))
_io = __io[0]
_io.each do |io|
worker = @workers_hash[io]
case worker.read
when /^done (.+?)$/
r = Marshal.load($1.unpack("m")[0])
result << r[0..1] unless r[0..1] == [nil,nil]
rep << {file: worker.real_file,
report: r[2], result: r[3], testcase: r[5]}
$:.push(*r[4]).uniq!
@ios.delete(io)
end
end
end
end
@workers.each do |worker|
begin
timeout(1) do
@ -500,9 +518,9 @@ module Test
rep.each do |r|
report.push(*r[:report])
end
@errors += rep.map{|x| x[:result][0] }.inject(:+)
@errors += rep.map{|x| x[:result][0] }.inject(:+)
@failures += rep.map{|x| x[:result][1] }.inject(:+)
@skips += rep.map{|x| x[:result][2] }.inject(:+)
@skips += rep.map{|x| x[:result][2] }.inject(:+)
else
puts ""
puts "Retrying..."

View file

@ -42,7 +42,12 @@ module Test
e, f, s = @errors, @failures, @skips
result = orig_run_suite(suite, type)
begin
result = orig_run_suite(suite, type)
rescue Interrupt
@need_exit = true
result = [nil,nil]
end
MiniTest::Unit.output = orig_stdout
@ -73,8 +78,8 @@ module Test
process_args args
@@stop_auto_run = true
@opts = @options.dup
@need_exit = false
Signal.trap(:INT,"IGNORE")
@old_loadpath = []
begin
@stdout = increment_io(STDOUT)
@ -101,7 +106,14 @@ module Test
end
_run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym
@stdout.puts "ready"
if @need_exit
begin
@stdout.puts "bye"
rescue Errno::EPIPE; end
exit
else
@stdout.puts "ready"
end
when /^quit$/
begin
@stdout.puts "bye"