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

ruby-changes:46068

From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 16:22:49 +0900 (JST)
Subject: [ruby-changes:46068] usa:r58139 (ruby_2_2): merge revision(s) 49806:

usa	2017-03-26 16:22:44 +0900 (Sun, 26 Mar 2017)

  New Revision: 58139

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

  Log:
    merge revision(s) 49806:
    
    envutil.rb: timeout_error argument to invoke_ruby
    
    * test/lib/envutil.rb (invoke_ruby): add `timeout_error` optional
      keyword argument, the exception class to be raised if the target
      process timed out.  if it is nil, no exception will be raised at
      timeout but the terminated output, error, and status will be
      returned.  defaulted to Timeout::Error.
    
    * test/lib/envutil.rb (assert_separately): check outputs and
      status (including diagnostic reports) of timed-out process.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/test/lib/envutil.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/test/lib/envutil.rb
===================================================================
--- ruby_2_2/test/lib/envutil.rb	(revision 58138)
+++ ruby_2_2/test/lib/envutil.rb	(revision 58139)
@@ -31,7 +31,7 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/lib/envutil.rb#L31
   LANG_ENVS = %w"LANG LC_ALL LC_CTYPE"
 
   def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = false,
-                  encoding: nil, timeout: 10, reprieve: 1,
+                  encoding: nil, timeout: 10, reprieve: 1, timeout_error: Timeout::Error,
                   stdout_filter: nil, stderr_filter: nil,
                   rubybin: EnvUtil.rubybin,
                   **opt)
@@ -63,10 +63,7 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/lib/envutil.rb#L63
       th_stderr = Thread.new { err_p.read } if capture_stderr && capture_stderr != :merge_to_stdout
       in_p.write stdin_data.to_str unless stdin_data.empty?
       in_p.close
-      if (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout))
-        stdout = th_stdout.value if capture_stdout
-        stderr = th_stderr.value if capture_stderr && capture_stderr != :merge_to_stdout
-      else
+      unless (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout))
         signal = /mswin|mingw/ =~ RUBY_PLATFORM ? :KILL : :TERM
         case pgroup = opt[:pgroup]
         when 0, true
@@ -87,13 +84,17 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/lib/envutil.rb#L84
         else
           break
         end while true
-        bt = caller_locations
-        raise Timeout::Error, "execution of #{bt.shift.label} expired", bt.map(&:to_s)
+        if timeout_error
+          bt = caller_locations
+          raise timeout_error, "execution of #{bt.shift.label} expired", bt.map(&:to_s)
+        end
+        status = $?
       end
+      stdout = th_stdout.value if capture_stdout
+      stderr = th_stderr.value if capture_stderr && capture_stderr != :merge_to_stdout
       out_p.close if capture_stdout
       err_p.close if capture_stderr && capture_stderr != :merge_to_stdout
-      Process.wait pid
-      status = $?
+      status ||= Process.wait2(pid)[1]
       stdout = stdout_filter.call(stdout) if stdout_filter
       stderr = stderr_filter.call(stderr) if stderr_filter
       return stdout, stderr, status
@@ -373,7 +374,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/lib/envutil.rb#L374
 eom
         args = args.dup
         args.insert((Hash === args.first ? 1 : 0), "-w", "--disable=gems", *$:.map {|l| "-I#{l}"})
-        stdout, stderr, status = EnvUtil.invoke_ruby(args, src, true, true, **opt)
+        stdout, stderr, status = EnvUtil.invoke_ruby(args, src, true, true, timeout_error: nil, **opt)
         abort = status.coredump? || (status.signaled? && ABORT_SIGNALS.include?(status.termsig))
         assert(!abort, FailDesc[status, nil, stderr])
         self._assertions += stdout[/^assertions=(\d+)/, 1].to_i
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 58138)
+++ ruby_2_2/ChangeLog	(revision 58139)
@@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Sun Mar 26 16:22:03 2017  Nobuyoshi Nakada  <nobu@r...>
+
+	envutil.rb: timeout_error argument to invoke_ruby
+
+	* test/lib/envutil.rb (invoke_ruby): add `timeout_error` optional
+	  keyword argument, the exception class to be raised if the target
+	  process timed out.  if it is nil, no exception will be raised at
+	  timeout but the terminated output, error, and status will be
+	  returned.  defaulted to Timeout::Error.
+
+	* test/lib/envutil.rb (assert_separately): check outputs and
+	  status (including diagnostic reports) of timed-out process.
+
 Sun Mar 26 13:07:21 2017  NAKAMURA Usaku  <usa@r...>
 
 	* thread.c (rb_thread_sleep_deadly_allow_spurious_wakeup): need to
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 58138)
+++ ruby_2_2/version.h	(revision 58139)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 465
+#define RUBY_PATCHLEVEL 466
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49806


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

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