summaryrefslogtreecommitdiff
path: root/bootstraptest/runner.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-14 12:48:12 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-14 12:48:12 +0000
commitb235e8f474b24b22162ed3feb8a0a3abec14f2e0 (patch)
tree17580a92aac656dc9eea4214ad6cf67056b85a49 /bootstraptest/runner.rb
parent7e8d337aa47a282f632b11d62503739251766463 (diff)
* bootstraptest/runner.rb (assert_check): new method.
(assert_match): new method. (assert_equal): use assert_check. (pretty): give failure description as an argument. * bootstraptest/test_exception.rb: use assert_match to describe the test for [ruby-dev:31407]. [ruby-dev:31412] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest/runner.rb')
-rw-r--r--bootstraptest/runner.rb34
1 files changed, 28 insertions, 6 deletions
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
index 0b2f14fbc6..5d550025e9 100644
--- a/bootstraptest/runner.rb
+++ b/bootstraptest/runner.rb
@@ -95,25 +95,47 @@ def exec_test(pathes)
end
end
-def assert_equal(expected, testsrc, message = '')
+def assert_check(testsrc, message = '')
newtest
$stderr.puts "\##{@count} #{@location}" if @verbose
result = get_result_string(testsrc)
check_coredump
- if expected == result
+ faildesc = yield(result)
+ if !faildesc
$stderr.print '.'
else
$stderr.print 'F'
- error pretty(testsrc, expected, result), message
+ error faildesc, message
end
rescue Exception => err
$stderr.print 'E'
error err.message, message
end
-def pretty(src, ex, result)
- (/\n/ =~ src ? "\n#{adjust_indent(src)}" : src) +
- " #=> #{result.inspect} (expected #{ex.inspect})"
+def assert_equal(expected, testsrc, message = '')
+ assert_check(testsrc, message) {|result|
+ if expected == result
+ nil
+ else
+ desc = "#{result.inspect} (expected #{expected.inspect})"
+ pretty(testsrc, desc, result)
+ end
+ }
+end
+
+def assert_match(expected_pattern, testsrc, message = '')
+ assert_check(testsrc, message) {|result|
+ if expected_pattern =~ result
+ nil
+ else
+ desc = "#{expected_pattern.inspect} expected to be =~\n#{result.inspect}"
+ pretty(testsrc, desc, result)
+ end
+ }
+end
+
+def pretty(src, desc, result)
+ (/\n/ =~ src ? "\n#{adjust_indent(src)}" : src) + " #=> #{desc}"
end
INDENT = 27