diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | bootstraptest/runner.rb | 49 | ||||
-rw-r--r-- | bootstraptest/test_knownbug.rb | 10 |
3 files changed, 61 insertions, 5 deletions
@@ -1,3 +1,10 @@ +Thu Sep 27 07:39:13 2007 Tanaka Akira <akr@fsij.org> + + * 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@ruby-lang.org> * encoding.c (rb_enc_associate_index): deal with ASCII compatible diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index 502eb64857..12acf290d1 100644 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -166,6 +166,39 @@ def assert_match(expected_pattern, testsrc, message = '') } 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 @@ def untabify(str) 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 diff --git a/bootstraptest/test_knownbug.rb b/bootstraptest/test_knownbug.rb index 39dc6a9b8b..a5088ac234 100644 --- a/bootstraptest/test_knownbug.rb +++ b/bootstraptest/test_knownbug.rb @@ -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]' |