summaryrefslogtreecommitdiff
path: root/bootstraptest/runner.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-26 22:40:44 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-26 22:40:44 +0000
commit654cdfb90ba127bcf453d3d45dc7a3f4c99a8c05 (patch)
tree22f159b6253602fa0ff9ac5705783806ab909c39 /bootstraptest/runner.rb
parent19d8793ef4df2183a1187eefae1c71009634e92b (diff)
* bootstraptest/runner.rb (assert_finish): new method.
* bootstraptest/test_knownbug.rb: add test for [ruby-dev:31866] using assert_finish. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest/runner.rb')
-rw-r--r--bootstraptest/runner.rb49
1 files changed, 44 insertions, 5 deletions
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
index 502eb64..12acf29 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