summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-26 07:22:44 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-26 07:22:44 +0000
commitb2cdb79c7a0dd8898c4a03129d9b21ff11985bf5 (patch)
tree8104e64207a2db5ddf6d694f79efea29c3dc0184 /test
parent7b9fffe6a4e8f7eed531178fc737a36a2122da78 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/lib/envutil.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/test/lib/envutil.rb b/test/lib/envutil.rb
index 4a48ee6ae6..7e3c7a08b1 100644
--- a/test/lib/envutil.rb
+++ b/test/lib/envutil.rb
@@ -31,7 +31,7 @@ module EnvUtil
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
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
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
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