[前][次][番号順一覧][スレッド一覧]

ruby-changes:45452

From: nobu <ko1@a...>
Date: Sat, 4 Feb 2017 12:28:22 +0900 (JST)
Subject: [ruby-changes:45452] nobu:r57525 (trunk): test/unit.rb: job tokens

nobu	2017-02-04 12:28:17 +0900 (Sat, 04 Feb 2017)

  New Revision: 57525

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57525

  Log:
    test/unit.rb: job tokens
    
    * test/lib/test/unit.rb (_run_parallel): deal with job tokens for
      each workers.

  Modified files:
    trunk/test/lib/test/unit.rb
Index: test/lib/test/unit.rb
===================================================================
--- test/lib/test/unit.rb	(revision 57524)
+++ test/lib/test/unit.rb	(revision 57525)
@@ -253,7 +253,6 @@ module Test https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L253
           return if @io.closed?
           @quit_called = true
           @io.puts "quit"
-          @io.close
         end
 
         def kill
@@ -296,6 +295,10 @@ module Test https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L295
       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 https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L314
       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 https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L384
           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 https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L447
         @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 https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L457
                 (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 https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L477
           end
 
           quit_workers
-          if @jobserver
-            @jobserver[1] << job_tokens
-            job_tokens.clear
-          end
 
           unless @interrupt || !@options[:retry] || @need_quit
             parallel = @options[:parallel]

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]