envutil.rb: abort at timeout
* test/lib/envutil.rb (invoke_ruby): abort at timeout and show the backtrace of the target process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
46b511cef4
commit
bac6ef1b87
@ -73,12 +73,14 @@ module EnvUtil
|
|||||||
th_stderr = Thread.new { err_p.read } if capture_stderr && capture_stderr != :merge_to_stdout
|
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.write stdin_data.to_str unless stdin_data.empty?
|
||||||
in_p.close
|
in_p.close
|
||||||
unless (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout))
|
if (!th_stdout || th_stdout.join(timeout)) && (!th_stderr || th_stderr.join(timeout))
|
||||||
|
timeout_error = nil
|
||||||
|
else
|
||||||
signals = Array(signal).select do |sig|
|
signals = Array(signal).select do |sig|
|
||||||
DEFAULT_SIGNALS[sig.to_s] or
|
DEFAULT_SIGNALS[sig.to_s] or
|
||||||
DEFAULT_SIGNALS[Signal.signame(sig)] rescue false
|
DEFAULT_SIGNALS[Signal.signame(sig)] rescue false
|
||||||
end
|
end
|
||||||
signals |= [:KILL]
|
signals |= [:ABRT, :KILL]
|
||||||
case pgroup = opt[:pgroup]
|
case pgroup = opt[:pgroup]
|
||||||
when 0, true
|
when 0, true
|
||||||
pgroup = -pid
|
pgroup = -pid
|
||||||
@ -102,10 +104,6 @@ module EnvUtil
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if timeout_error
|
|
||||||
bt = caller_locations
|
|
||||||
raise timeout_error, "execution of #{bt.shift.label} expired", bt.map(&:to_s)
|
|
||||||
end
|
|
||||||
status = $?
|
status = $?
|
||||||
end
|
end
|
||||||
stdout = th_stdout.value if capture_stdout
|
stdout = th_stdout.value if capture_stdout
|
||||||
@ -115,6 +113,12 @@ module EnvUtil
|
|||||||
status ||= Process.wait2(pid)[1]
|
status ||= Process.wait2(pid)[1]
|
||||||
stdout = stdout_filter.call(stdout) if stdout_filter
|
stdout = stdout_filter.call(stdout) if stdout_filter
|
||||||
stderr = stderr_filter.call(stderr) if stderr_filter
|
stderr = stderr_filter.call(stderr) if stderr_filter
|
||||||
|
if timeout_error
|
||||||
|
bt = caller_locations
|
||||||
|
msg = "execution of #{bt.shift.label} expired"
|
||||||
|
msg = Test::Unit::Assertions::FailDesc[status, msg, [stdout, stderr].join("\n")].()
|
||||||
|
raise timeout_error, msg, bt.map(&:to_s)
|
||||||
|
end
|
||||||
return stdout, stderr, status
|
return stdout, stderr, status
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
Loading…
x
Reference in New Issue
Block a user