diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-25 02:10:38 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-25 02:10:38 +0000 |
commit | 6b7304cb61b28bc3faf8fac53d73665585c150b9 (patch) | |
tree | b927c261c83ff0280b2bde69e49a78caf05a0ad4 /bootstraptest | |
parent | cd87465d28ea819eea97fcb45a780058a03cfe78 (diff) | |
download | ruby-6b7304cb61b28bc3faf8fac53d73665585c150b9.tar.gz ruby-6b7304cb61b28bc3faf8fac53d73665585c150b9.tar.xz ruby-6b7304cb61b28bc3faf8fac53d73665585c150b9.zip |
* bootstraptest/runner.rb: show source code in error message.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/runner.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index 8fc3bc2e0..ed2880903 100644 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -9,7 +9,7 @@ $LOAD_PATH.unshift "#{File.dirname($0)}/lib" require 'fileutils' def main - @ruby = nil + @ruby = File.expand_path('miniruby') @verbose = false dir = 'bootstraptest.tmpwd' tests = nil @@ -69,22 +69,37 @@ def exec_test(pathes) end end -def assert_equal(expected, really) +def assert_equal(expected, testsrc) newtest $stderr.puts "\##{@count} #{@location}" if @verbose - restr = get_result_string(really) + result = get_result_string(testsrc) check_coredump - if expected == restr + if expected == result $stderr.print '.' else $stderr.print 'F' - error "expected #{expected.inspect} but is: #{restr.inspect}" + error pretty(testsrc, expected, result) end rescue Exception => err $stderr.print 'E' error err.message 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) if @ruby File.open('bootstraptest.tmp.rb', 'w') {|f| |