1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* bootstraptest/runner.rb: show source code in error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aamine 2007-02-25 02:10:38 +00:00
parent 71986ef6bc
commit 565bcdcb30
2 changed files with 24 additions and 5 deletions

View file

@ -1,3 +1,7 @@
Sun Feb 25 11:09:16 2007 Minero Aoki <aamine@loveruby.net>
* bootstraptest/runner.rb: show source code in error message.
Sun Feb 25 09:39:50 2007 Koichi Sasada <ko1@atdot.net> Sun Feb 25 09:39:50 2007 Koichi Sasada <ko1@atdot.net>
* yarvcore.h: * yarvcore.h:

View file

@ -9,7 +9,7 @@ $LOAD_PATH.unshift "#{File.dirname($0)}/lib"
require 'fileutils' require 'fileutils'
def main def main
@ruby = nil @ruby = File.expand_path('miniruby')
@verbose = false @verbose = false
dir = 'bootstraptest.tmpwd' dir = 'bootstraptest.tmpwd'
tests = nil tests = nil
@ -69,22 +69,37 @@ def exec_test(pathes)
end end
end end
def assert_equal(expected, really) def assert_equal(expected, testsrc)
newtest newtest
$stderr.puts "\##{@count} #{@location}" if @verbose $stderr.puts "\##{@count} #{@location}" if @verbose
restr = get_result_string(really) result = get_result_string(testsrc)
check_coredump check_coredump
if expected == restr if expected == result
$stderr.print '.' $stderr.print '.'
else else
$stderr.print 'F' $stderr.print 'F'
error "expected #{expected.inspect} but is: #{restr.inspect}" error pretty(testsrc, expected, result)
end end
rescue Exception => err rescue Exception => err
$stderr.print 'E' $stderr.print 'E'
error err.message error err.message
end end
def pretty(src, ex, result)
(/\n/ =~ src ? "\n#{adjust_indent(src)}" : src) +
" #=> #{result.inspect} (expected #{ex.inspect})"
end
INDENT = 27
def adjust_indent(src)
untabify(src).gsub(/^ {#{INDENT}}/o, '').gsub(/^/, ' ')
end
def untabify(str)
str.gsub(/^\t+/) {|tabs| ' ' * (8 * tabs.size) }
end
def get_result_string(src) def get_result_string(src)
if @ruby if @ruby
File.open('bootstraptest.tmp.rb', 'w') {|f| File.open('bootstraptest.tmp.rb', 'w') {|f|