* lib/test/unit.rb: warn when test_* method is redefined.

Patch by mame (Yusuke Endoh). [Feature #2643] [ruby-core:27790]

* test/testunit/test_redefinition.rb: Test for above.

* test/testunit/test4test_redefinition.rb: Ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
sorah 2012-07-21 05:12:32 +00:00
Родитель c4827de949
Коммит 7773a911f5
4 изменённых файлов: 44 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,12 @@
Sat Jul 21 14:06:41 2012 Shota Fukumori <sorah@tubusu.net>
* lib/test/unit.rb: warn when test_* method is redefined.
Patch by mame (Yusuke Endoh). [Feature #2643] [ruby-core:27790]
* test/testunit/test_redefinition.rb: Test for above.
* test/testunit/test4test_redefinition.rb: Ditto.
Sat Jul 21 08:41:14 2012 Eric Hodel <drbrain@segment7.net>
* lib/logger.rb: Updated example in Logger comment to match other

Просмотреть файл

@ -20,6 +20,17 @@ module Test
def self.test_order
:sorted
end
Methods = {}
def self.method_added(name)
return unless name.to_s[/\Atest_/]
Methods[self] ||= {}
if Methods[self][name]
warn("test/unit warning: method #{ self }##{ name } is redefined")
end
Methods[self][name] = true
end
end
end
end

Просмотреть файл

@ -0,0 +1,11 @@
require 'test/unit'
class TestForTestRedefinition < Test::Unit::TestCase
def test_redefinition
skip "do nothing (1)"
end
def test_redefinition
skip "do nothing (2)"
end
end

Просмотреть файл

@ -0,0 +1,13 @@
require 'test/unit'
class TestHideSkip < Test::Unit::TestCase
def test_hideskip
test_out, o = IO.pipe
spawn(*@options[:ruby], "#{File.dirname(__FILE__)}/test4test_redefinition.rb", out: File::NULL, err: o)
o.close
assert_match /^test\/unit warning: method TestForTestRedefinition#test_redefinition is redefined$/,
test_out.read
test_out.close
end
end