summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-04 03:28:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-04 03:28:17 +0000
commit1f23dd016b1af529a00a5bbeae49dddc7d9c3969 (patch)
tree72f490286d3db744c381422ccaaba72df73afdcc
parent36037442bebe0c3d970141bb2d2c487fa7e03827 (diff)
test/unit.rb: job tokens
* test/lib/test/unit.rb (_run_parallel): deal with job tokens for each workers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/lib/test/unit.rb24
1 files changed, 15 insertions, 9 deletions
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb
index c092018..c0662f5 100644
--- a/test/lib/test/unit.rb
+++ b/test/lib/test/unit.rb
@@ -253,7 +253,6 @@ module Test
return if @io.closed?
@quit_called = true
@io.puts "quit"
- @io.close
end
def kill
@@ -296,6 +295,10 @@ module Test
def after_worker_down(worker, e=nil, c=false)
return unless @options[:parallel]
return if @interrupt
+ if @jobserver
+ @jobserver[1] << @job_tokens
+ @job_tokens.clear
+ end
warn e if e
real_file = worker.real_file and warn "running file: #{real_file}"
@need_quit = true
@@ -311,6 +314,10 @@ module Test
def after_worker_quit(worker)
return unless @options[:parallel]
return if @interrupt
+ worker.close
+ if @jobserver and !@job_tokens.empty?
+ @jobserver[1] << @job_tokens.slice!(0)
+ end
@workers.delete(worker)
@dead_workers << worker
@ios = @workers.map(&:io)
@@ -377,7 +384,10 @@ module Test
bang = $1
worker.status = :ready
- return nil unless task = @tasks.shift
+ unless task = @tasks.shift
+ worker.quit
+ return nil
+ end
if @options[:separate] and not bang
worker.quit
worker = add_worker
@@ -437,7 +447,7 @@ module Test
@workers = [] # Array of workers.
@workers_hash = {} # out-IO => worker
@ios = [] # Array of worker IOs
- job_tokens = String.new(encoding: Encoding::ASCII_8BIT) if @jobserver
+ @job_tokens = String.new(encoding: Encoding::ASCII_8BIT) if @jobserver
begin
[@tasks.size, @options[:parallel]].min.times {launch_worker}
@@ -447,10 +457,10 @@ module Test
(deal(io, type, result, rep).nil? and
!@workers.any? {|x| [:running, :prepare].include? x.status})
end
- if job_tokens and !@tasks.empty? and !@workers.any? {|x| x.status == :ready}
+ if @job_tokens and !@tasks.empty? and !@workers.any? {|x| x.status == :ready}
t = @jobserver[0].read_nonblock([@tasks.size, @options[:parallel]].min, exception: false)
if String === t
- job_tokens << t
+ @job_tokens << t
t.size.times {launch_worker}
end
end
@@ -467,10 +477,6 @@ module Test
end
quit_workers
- if @jobserver
- @jobserver[1] << job_tokens
- job_tokens.clear
- end
unless @interrupt || !@options[:retry] || @need_quit
parallel = @options[:parallel]