* bootstraptest/runner.rb (assert_normal_exit): add :timeout option.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-02-17 12:27:34 +00:00
parent 50c8982ea8
commit 24421c835d
3 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,7 @@
Wed Feb 17 21:26:53 2010 Tanaka Akira <akr@fsij.org>
* bootstraptest/runner.rb (assert_normal_exit): add :timeout option.
Wed Feb 17 17:05:39 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Feb 17 17:05:39 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_call_cfunc): removed unused variable. * vm_insnhelper.c (vm_call_cfunc): removed unused variable.

View File

@ -3,7 +3,7 @@
# So all tests will cause failure. # So all tests will cause failure.
# #
assert_finish 1, %q{ assert_normal_exit %q{
open("tst-remove-load.rb", "w") {|f| open("tst-remove-load.rb", "w") {|f|
f << <<'End' f << <<'End'
module Kernel module Kernel
@ -13,4 +13,4 @@ raise
End End
} }
load "tst-remove-load.rb" load "tst-remove-load.rb"
}, '[ruby-dev:40234] [ruby-core:27959]' }, '[ruby-dev:40234] [ruby-core:27959]', :timeout => 1

View File

@ -213,16 +213,32 @@ def assert_valid_syntax(testsrc, message = '')
} }
end end
def assert_normal_exit(testsrc, message = '', ignore_signals = nil) def assert_normal_exit(testsrc, *rest)
opt = {}
opt = rest.pop if Hash === rest.last
message, ignore_signals = rest
message ||= ''
timeout = opt[:timeout]
newtest newtest
$stderr.puts "\##{@count} #{@location}" if @verbose $stderr.puts "\##{@count} #{@location}" if @verbose
faildesc = nil faildesc = nil
filename = make_srcfile(testsrc) filename = make_srcfile(testsrc)
old_stderr = $stderr.dup old_stderr = $stderr.dup
timeout_signaled = false
begin begin
$stderr.reopen("assert_normal_exit_stderr.log", "w") $stderr.reopen("assert_normal_exit.log", "w")
`#{@ruby} -W0 #{filename}` io = IO.popen("#{@ruby} -W0 #{filename}")
status = $? pid = io.pid
th = Thread.new {
io.read
io.close
$?
}
if !th.join(timeout)
Process.kill :KILL, pid
timeout_signaled = true
end
status = th.value
ensure ensure
$stderr.reopen(old_stderr) $stderr.reopen(old_stderr)
old_stderr.close old_stderr.close
@ -235,8 +251,11 @@ def assert_normal_exit(testsrc, message = '', ignore_signals = nil)
if signame if signame
sigdesc = "SIG#{signame} (#{sigdesc})" sigdesc = "SIG#{signame} (#{sigdesc})"
end end
if timeout_signaled
sigdesc << " (timeout)"
end
faildesc = pretty(testsrc, "killed by #{sigdesc}", nil) faildesc = pretty(testsrc, "killed by #{sigdesc}", nil)
stderr_log = File.read("assert_normal_exit_stderr.log") stderr_log = File.read("assert_normal_exit.log")
if !stderr_log.empty? if !stderr_log.empty?
faildesc << "\n" if /\n\z/ !~ faildesc faildesc << "\n" if /\n\z/ !~ faildesc
stderr_log << "\n" if /\n\z/ !~ stderr_log stderr_log << "\n" if /\n\z/ !~ stderr_log