diff options
author | ntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-02 23:03:13 +0000 |
---|---|---|
committer | ntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-02 23:03:13 +0000 |
commit | 47bd3ed9ce1bfe9116925b95f4c2b342e864af5a (patch) | |
tree | d0b9e0216e099df5b9f77378956d50c59a7cc320 /lib/test/unit/error.rb | |
parent | 56db4c8fb04617549c4b1c3aee3a39b3a4adada9 (diff) | |
download | ruby-47bd3ed9ce1bfe9116925b95f4c2b342e864af5a.tar.gz |
* lib/test/unit/assertions.rb: added a default message for #assert,
#assert_block, and #flunk.
* test/testunit/test_assertions.rb: ditto.
* lib/test/unit/failure.rb: failures now show a better trace of where
they occurred.
* test/testunit/test_failure.rb: ditto (added).
* lib/test/unit/testcase.rb: ditto.
* test/testunit/test_testcase.rb: ditto.
* lib/test/unit/util/backtracefilter.rb: added.
* test/testunit/util/test_backtracefilter.rb: added.
* lib/test/unit/error.rb: changed to use BacktraceFilter and improved
output.
* test/testunit/test_error.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/test/unit/error.rb')
-rw-r--r-- | lib/test/unit/error.rb | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/lib/test/unit/error.rb b/lib/test/unit/error.rb index 46c6663d86..90ac04cf3b 100644 --- a/lib/test/unit/error.rb +++ b/lib/test/unit/error.rb @@ -4,6 +4,8 @@ # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. # License:: Ruby license. +require 'test/unit/util/backtracefilter' + module Test module Unit @@ -11,14 +13,16 @@ module Test # Test::Unit::TestCase when it rescues an exception thrown # during the processing of a test. class Error - attr_reader(:location, :exception) + include Util::BacktraceFilter + + attr_reader(:test_name, :exception) SINGLE_CHARACTER = 'E' - # Creates a new Error with the given location and + # Creates a new Error with the given test_name and # exception. - def initialize(location, exception) - @location = location + def initialize(test_name, exception) + @test_name = test_name @exception = exception end @@ -34,35 +38,19 @@ module Test # Returns a brief version of the error description. def short_display - "#{@location}:\n#{message}" + "#@test_name: #{message.split("\n")[0]}" end # Returns a verbose version of the error description. def long_display - backtrace = self.class.filter(@exception.backtrace).join("\n ") - "Error!!!\n#{short_display}\n #{backtrace}" + backtrace = filter_backtrace(@exception.backtrace).join("\n ") + "Error:\n#@test_name:\n#{message}\n #{backtrace}" end # Overridden to return long_display. def to_s long_display end - - SEPARATOR_PATTERN = '[\\\/:]' - def self.filter(backtrace) # :nodoc: - @test_unit_patterns ||= $:.collect { - | path | - /^#{Regexp.escape(path)}#{SEPARATOR_PATTERN}test#{SEPARATOR_PATTERN}unit#{SEPARATOR_PATTERN}/ - }.push(/#{SEPARATOR_PATTERN}test#{SEPARATOR_PATTERN}unit\.rb/) - - return backtrace.delete_if { - | line | - @test_unit_patterns.detect { - | pattern | - line =~ pattern - } - } - end end end end |