mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
envutil.rb: crash report on Mac OS X
* test/ruby/envutil.rb (EnvUtil.diagnostic_reports): find crash report on Mac OS X. * test/ruby/envutil.rb (Test::Unit::Assertions::FailDesc): include crash report on Mac OS X. * test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err): remove crash reports if exist. * test/ruby/test_process.rb (TestProcess#test_status_kill): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
006eca88cf
commit
6e3184e25a
2 changed files with 38 additions and 0 deletions
|
@ -155,6 +155,34 @@ module EnvUtil
|
||||||
$VERBOSE = verbose
|
$VERBOSE = verbose
|
||||||
end
|
end
|
||||||
module_function :with_default_internal
|
module_function :with_default_internal
|
||||||
|
|
||||||
|
if /darwin/ =~ RUBY_PLATFORM
|
||||||
|
DIAGNOSTIC_REPORTS_PATH = File.expand_path("~/Library/Logs/DiagnosticReports")
|
||||||
|
DIAGNOSTIC_REPORTS_TIMEFORMAT = '%Y-%m-%d-%H%M%S'
|
||||||
|
def self.diagnostic_reports(signame, cmd, pid, now)
|
||||||
|
return unless %w[ABRT QUIT SEGV ILL].include?(signame)
|
||||||
|
cmd = File.basename(cmd)
|
||||||
|
path = DIAGNOSTIC_REPORTS_PATH
|
||||||
|
timeformat = DIAGNOSTIC_REPORTS_TIMEFORMAT
|
||||||
|
pat = "#{path}/#{cmd}_#{now.strftime(timeformat)}[-_]*.crash"
|
||||||
|
first = true
|
||||||
|
3.times do
|
||||||
|
first ? (first = false) : sleep(1)
|
||||||
|
Dir.glob(pat) do |name|
|
||||||
|
log = File.read(name) rescue next
|
||||||
|
if /\AProcess:\s+#{cmd} \[#{pid}\]$/ =~ log
|
||||||
|
File.unlink(name)
|
||||||
|
File.unlink("#{path}/.#{File.basename(name)}.plist")
|
||||||
|
return log
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
def self.diagnostic_reports(signame, cmd, pid, now)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Test
|
module Test
|
||||||
|
@ -221,10 +249,12 @@ module Test
|
||||||
|
|
||||||
FailDesc = proc do |status, message = "", out = ""|
|
FailDesc = proc do |status, message = "", out = ""|
|
||||||
pid = status.pid
|
pid = status.pid
|
||||||
|
now = Time.now
|
||||||
faildesc = proc do
|
faildesc = proc do
|
||||||
signo = status.termsig
|
signo = status.termsig
|
||||||
signame = Signal.signame(signo)
|
signame = Signal.signame(signo)
|
||||||
sigdesc = "signal #{signo}"
|
sigdesc = "signal #{signo}"
|
||||||
|
log = EnvUtil.diagnostic_reports(signame, EnvUtil.rubybin, pid, now)
|
||||||
if signame
|
if signame
|
||||||
sigdesc = "SIG#{signame} (#{sigdesc})"
|
sigdesc = "SIG#{signame} (#{sigdesc})"
|
||||||
end
|
end
|
||||||
|
@ -240,6 +270,9 @@ module Test
|
||||||
full_message << "\n#{out.gsub(/^/, '| ')}"
|
full_message << "\n#{out.gsub(/^/, '| ')}"
|
||||||
full_message << "\n" if /\n\z/ !~ full_message
|
full_message << "\n" if /\n\z/ !~ full_message
|
||||||
end
|
end
|
||||||
|
if log
|
||||||
|
full_message << "\n#{log.gsub(/^/, '| ')}"
|
||||||
|
end
|
||||||
full_message
|
full_message
|
||||||
end
|
end
|
||||||
faildesc
|
faildesc
|
||||||
|
@ -247,6 +280,9 @@ module Test
|
||||||
|
|
||||||
def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil, **opt)
|
def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil, **opt)
|
||||||
stdout, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, true, true, **opt)
|
stdout, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, true, true, **opt)
|
||||||
|
if signo = status.termsig
|
||||||
|
EnvUtil.diagnostic_reports(Signal.signame(signo), EnvUtil.rubybin, status.pid, Time.now)
|
||||||
|
end
|
||||||
if block_given?
|
if block_given?
|
||||||
raise "test_stdout ignored, use block only or without block" if test_stdout != []
|
raise "test_stdout ignored, use block only or without block" if test_stdout != []
|
||||||
raise "test_stderr ignored, use block only or without block" if test_stderr != []
|
raise "test_stderr ignored, use block only or without block" if test_stderr != []
|
||||||
|
|
|
@ -1190,6 +1190,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
pid = spawn(RUBY, "foo")
|
pid = spawn(RUBY, "foo")
|
||||||
Thread.new { sleep 1; Process.kill(:SIGQUIT, pid) }
|
Thread.new { sleep 1; Process.kill(:SIGQUIT, pid) }
|
||||||
Process.wait(pid)
|
Process.wait(pid)
|
||||||
|
t = Time.now
|
||||||
s = $?
|
s = $?
|
||||||
assert_equal([false, true, false],
|
assert_equal([false, true, false],
|
||||||
[s.exited?, s.signaled?, s.stopped?],
|
[s.exited?, s.signaled?, s.stopped?],
|
||||||
|
@ -1201,6 +1202,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
s.inspect])
|
s.inspect])
|
||||||
assert_equal(false, s.exited?)
|
assert_equal(false, s.exited?)
|
||||||
assert_equal(nil, s.success?)
|
assert_equal(nil, s.success?)
|
||||||
|
EnvUtil.diagnostic_reports("QUIT", RUBY, pid, t)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue