ruby-changes:14835
From: akr <ko1@a...>
Date: Wed, 17 Feb 2010 21:27:49 +0900 (JST)
Subject: [ruby-changes:14835] Ruby:r26700 (trunk): * bootstraptest/runner.rb (assert_normal_exit): add :timeout option.
akr 2010-02-17 21:27:34 +0900 (Wed, 17 Feb 2010) New Revision: 26700 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26700 Log: * bootstraptest/runner.rb (assert_normal_exit): add :timeout option. Modified files: trunk/ChangeLog trunk/KNOWNBUGS.rb trunk/bootstraptest/runner.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26699) +++ ChangeLog (revision 26700) @@ -1,3 +1,7 @@ +Wed Feb 17 21:26:53 2010 Tanaka Akira <akr@f...> + + * bootstraptest/runner.rb (assert_normal_exit): add :timeout option. + Wed Feb 17 17:05:39 2010 Nobuyoshi Nakada <nobu@r...> * vm_insnhelper.c (vm_call_cfunc): removed unused variable. Index: bootstraptest/runner.rb =================================================================== --- bootstraptest/runner.rb (revision 26699) +++ bootstraptest/runner.rb (revision 26700) @@ -213,16 +213,32 @@ } 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 $stderr.puts "\##{@count} #{@location}" if @verbose faildesc = nil filename = make_srcfile(testsrc) old_stderr = $stderr.dup + timeout_signaled = false begin - $stderr.reopen("assert_normal_exit_stderr.log", "w") - `#{@ruby} -W0 #{filename}` - status = $? + $stderr.reopen("assert_normal_exit.log", "w") + io = IO.popen("#{@ruby} -W0 #{filename}") + 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 $stderr.reopen(old_stderr) old_stderr.close @@ -235,8 +251,11 @@ if signame sigdesc = "SIG#{signame} (#{sigdesc})" end + if timeout_signaled + sigdesc << " (timeout)" + end 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? faildesc << "\n" if /\n\z/ !~ faildesc stderr_log << "\n" if /\n\z/ !~ stderr_log Index: KNOWNBUGS.rb =================================================================== --- KNOWNBUGS.rb (revision 26699) +++ KNOWNBUGS.rb (revision 26700) @@ -3,7 +3,7 @@ # So all tests will cause failure. # -assert_finish 1, %q{ +assert_normal_exit %q{ open("tst-remove-load.rb", "w") {|f| f << <<'End' module Kernel @@ -13,4 +13,4 @@ End } load "tst-remove-load.rb" -}, '[ruby-dev:40234] [ruby-core:27959]' +}, '[ruby-dev:40234] [ruby-core:27959]', :timeout => 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/