Skip to content

Commit

Permalink
Pull up EXCLUDES hacks into test/lib's minitest.
Browse files Browse the repository at this point in the history
Psych and a few other suites use minitest directly, bypassing the
test/unit EXCLUDES hacks I added earlier. This commit pulls my
hacks up into minitest, so that those other suites also see our
excluded tests.
  • Loading branch information
headius committed Nov 2, 2014
1 parent 4d82e39 commit 47b4623
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
34 changes: 33 additions & 1 deletion test/mri/lib/minitest/unit.rb
Expand Up @@ -1362,7 +1362,39 @@ def self.make_my_diffs_pretty!

def self.inherited klass # :nodoc:
@@test_suites[klass] = true
super
result = super

if ENV["EXCLUDES"]
begin
exclude_src = File.read File.join(ENV["EXCLUDES"], klass.inspect.gsub("::", "/") + ".rb")
excludes = {}
klass.send :instance_variable_set, :@excludes, excludes

klass.instance_eval do
def exclude(name, reason)
@excludes[name] = reason
end
end

klass.class_eval exclude_src
rescue Errno::ENOENT
# no excludes for this class
end
end

result
end

class << self
alias method_added_without_excludes method_added
end
def self.method_added(name)
if @excludes && @excludes[name]
remove_method name
return false
end

method_added_without_excludes(name)
end

def self.test_order # :nodoc:
Expand Down
27 changes: 0 additions & 27 deletions test/mri/lib/test/unit/testcase.rb
Expand Up @@ -35,33 +35,6 @@ def self.method_added(name)
end
@test_methods[name] = true
end

class << self
alias inherited_without_excludes inherited
def inherited(sub_class)
result = inherited_without_excludes(sub_class)

if ENV["EXCLUDES"]
begin
exclude_src = File.read File.join(ENV["EXCLUDES"], sub_class.inspect.gsub("::", "/") + ".rb")
excludes = {}
sub_class.send :instance_variable_set, :@excludes, excludes

sub_class.instance_eval do
def exclude(name, reason)
@excludes[name] = reason
end
end

sub_class.class_eval exclude_src
rescue Errno::ENOENT
# no excludes for this class
end
end

result
end
end
end
end
end

0 comments on commit 47b4623

Please sign in to comment.