From 63ca916ed414649e294b8dab1a30872c865a9faf Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 13 Feb 2011 10:41:59 +0000 Subject: [PATCH] * lib/test/unit.rb (Test::Unit::RequireFiles#non_options): skip test suites failed to load instead of mere messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/test/unit.rb | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5053f15f20..2825ab6b3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Feb 13 19:41:47 2011 Nobuyoshi Nakada + + * lib/test/unit.rb (Test::Unit::RequireFiles#non_options): skip + test suites failed to load instead of mere messages. + Sun Feb 13 09:56:44 2011 Nobuyoshi Nakada * test/openssl/test_config.rb (OpenSSL#test_freeze): fix error diff --git a/lib/test/unit.rb b/lib/test/unit.rb index fd50d8100d..c9637b97e7 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -166,6 +166,9 @@ module Test end module RequireFiles + path = File.expand_path('../../rubygems/custom_require.rb', __FILE__) + CUSTOM_REQUIRE = /\A#{Regexp.quote(path)}:\d+:in `require'\z/ #' + def non_options(files, options) return false if !super result = false @@ -177,8 +180,17 @@ module Test begin require path result = true - rescue LoadError - puts "#{f}: #{$!}" + rescue LoadError => e + Class.new(Test::Unit::TestCase) do + message = e.message + / -- (?.*)/ =~ message + define_singleton_method(:to_s) {failed} + backtrace = e.backtrace + backtrace.shift while CUSTOM_REQUIRE =~ backtrace.first + /(?.*):(?\d+):in\s`/ =~ backtrace.first + line = line.to_i + define_method(:test_require_failed) {eval "skip(message)", nil, file, line} + end end } result