summaryrefslogtreecommitdiff
path: root/test/lib/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-04 13:33:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-04 13:33:35 +0000
commit1b7efc132acb0c28ead3784f88089462ffa86691 (patch)
treec262e420c609ece067081d68bc3b7f30b5e955b7 /test/lib/test
parent54bfb33366b21321e7093e454935a35a488dbb25 (diff)
test/unit.rb: ExcludesOption
* test/lib/test/unit.rb (ExcludesOption): add "excludes" support to test suite, for alternative implementations and platforms. [Feature #10682] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/lib/test')
-rw-r--r--test/lib/test/unit.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb
index 048fc19..8f6cecf 100644
--- a/test/lib/test/unit.rb
+++ b/test/lib/test/unit.rb
@@ -835,6 +835,59 @@ module Test
end
end
+ module ExcludesOption # :nodoc: all
+ class ExcludedMethods < Struct.new(:excludes)
+ def exclude(name, reason)
+ excludes[name] = reason
+ end
+
+ def exclude_from(klass)
+ excludes = self.excludes
+ klass.class_eval do
+ public_instance_methods(false).each do |method|
+ if excludes[method]
+ remove_method(method)
+ end
+ end
+ public_instance_methods(true).each do |method|
+ if excludes[method]
+ undef_method(method)
+ end
+ end
+ end
+ end
+
+ def self.load(dir, name)
+ return unless dir and name
+ path = File.join(dir, name.gsub(/::/, '/') + ".rb")
+ begin
+ src = File.read(path)
+ rescue Errno::ENOENT
+ nil
+ else
+ instance = new({})
+ instance.instance_eval(src)
+ instance
+ end
+ end
+ end
+
+ def setup_options(parser, options)
+ super
+ options[:excludes] = ENV["EXCLUDES"]
+ parser.on '-X', '--excludes-dir DIRECTORY', "Directory name of exclude files" do |d|
+ options[:excludes] = d
+ end
+ end
+
+ def _run_suite(suite, type)
+ if ex = ExcludedMethods.load(@options[:excludes], suite.name)
+ ex.exclude_from(suite)
+ end
+ super
+ end
+ end
+
class Runner < MiniTest::Unit # :nodoc: all
include Test::Unit::Options
include Test::Unit::StatusLine
@@ -843,6 +896,7 @@ module Test
include Test::Unit::GlobOption
include Test::Unit::LoadPathOption
include Test::Unit::GCStressOption
+ include Test::Unit::ExcludesOption
include Test::Unit::RunCount
class << self; undef autorun; end