ruby-changes:2040
From: ko1@a...
Date: 27 Sep 2007 07:41:08 +0900
Subject: [ruby-changes:2040] akr - Ruby:r13531 (trunk): * bootstraptest/runner.rb (assert_finish): new method.
akr 2007-09-27 07:40:44 +0900 (Thu, 27 Sep 2007)
New Revision: 13531
Modified files:
trunk/ChangeLog
trunk/bootstraptest/runner.rb
trunk/bootstraptest/test_knownbug.rb
Log:
* bootstraptest/runner.rb (assert_finish): new method.
* bootstraptest/test_knownbug.rb: add test for [ruby-dev:31866] using
assert_finish.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13531&r2=13530
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/runner.rb?r1=13531&r2=13530
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_knownbug.rb?r1=13531&r2=13530
Index: ChangeLog
===================================================================
--- ChangeLog (revision 13530)
+++ ChangeLog (revision 13531)
@@ -1,3 +1,10 @@
+Thu Sep 27 07:39:13 2007 Tanaka Akira <akr@f...>
+
+ * bootstraptest/runner.rb (assert_finish): new method.
+
+ * bootstraptest/test_knownbug.rb: add test for [ruby-dev:31866] using
+ assert_finish.
+
Thu Sep 27 04:46:31 2007 Nobuyoshi Nakada <nobu@r...>
* encoding.c (rb_enc_associate_index): deal with ASCII compatible
Index: bootstraptest/runner.rb
===================================================================
--- bootstraptest/runner.rb (revision 13530)
+++ bootstraptest/runner.rb (revision 13531)
@@ -166,6 +166,39 @@
}
end
+def assert_finish(timeout_seconds, testsrc, message = '')
+ newtest
+ $stderr.puts "\##{@count} #{@location}" if @verbose
+ faildesc = nil
+ filename = make_srcfile(testsrc)
+ io = IO.popen("#{@ruby} -W0 #{filename}")
+ pid = io.pid
+ waited = false
+ tlimit = Time.now + timeout_seconds
+ while Time.now < tlimit
+ if Process.waitpid pid, Process::WNOHANG
+ waited = true
+ break
+ end
+ sleep 0.1
+ end
+ if !waited
+ Process.kill(:KILL, pid)
+ Process.waitpid pid
+ faildesc = pretty(testsrc, "not finished in #{timeout_seconds} seconds", nil)
+ end
+ io.close
+ if !faildesc
+ $stderr.print '.'
+ else
+ $stderr.print 'F'
+ error faildesc, message
+ end
+rescue Exception => err
+ $stderr.print 'E'
+ error err.message, message
+end
+
def pretty(src, desc, result)
(/\n/ =~ src ? "\n#{adjust_indent(src)}" : src) + " #=> #{desc}"
end
@@ -180,14 +213,20 @@
str.gsub(/^\t+/) {|tabs| ' ' * (8 * tabs.size) }
end
+def make_srcfile(src)
+ filename = 'bootstraptest.tmp.rb'
+ File.open(filename, 'w') {|f|
+ f.puts "GC.stress = true" if $stress
+ f.puts "print(begin; #{src}; end)"
+ }
+ filename
+end
+
def get_result_string(src)
if @ruby
- File.open('bootstraptest.tmp.rb', 'w') {|f|
- f.puts "GC.stress = true" if $stress
- f.puts "print(begin; #{src}; end)"
- }
+ filename = make_srcfile(src)
begin
- `#{@ruby} -W0 bootstraptest.tmp.rb`
+ `#{@ruby} -W0 #{filename}`
ensure
raise CoreDumpError, "core dumped" if $? and $?.coredump?
end
Index: bootstraptest/test_knownbug.rb
===================================================================
--- bootstraptest/test_knownbug.rb (revision 13530)
+++ bootstraptest/test_knownbug.rb (revision 13531)
@@ -2,3 +2,13 @@
# This test file concludes tests which point out known bugs.
# So all tests will cause failure.
#
+
+assert_finish 1, %q{
+ r, w = IO.pipe
+ t1 = Thread.new { r.sysread(10) }
+ t2 = Thread.new { r.sysread(10) }
+ sleep 0.1
+ w.write "a"
+ sleep 0.1
+ w.write "a"
+}, '[ruby-dev:31866]'
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml