Created
June 7, 2024 21:01
-
-
Save zenspider/b67c3f2ca4e9d8cea84b6379e96ffa64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r old/lib/minitest.rb new/lib/minitest.rb | |
--- old/lib/minitest.rb | |
+++ new/lib/minitest.rb | |
@@ -99,12 +99,10 @@ | |
end | |
def self.load_plugins # :nodoc: | |
- return unless self.extensions.empty? | |
+ return unless defined? Gem | |
seen = {} | |
- require "rubygems" unless defined? Gem | |
- | |
Gem.find_files("minitest/*_plugin.rb").each do |plugin_path| | |
name = File.basename plugin_path, "_plugin.rb" | |
@@ -117,9 +115,20 @@ | |
end | |
def self.init_plugins options # :nodoc: | |
- self.extensions.each do |name| | |
- msg = "plugin_#{name}_init" | |
- send msg, options if self.respond_to? msg | |
+ self.extensions.each do |mod_or_meth| | |
+ case mod_or_meth | |
+ when Symbol, String then | |
+ name = mod_or_meth | |
+ msg = "plugin_#{name}_init" | |
+ next unless self.respond_to? msg | |
+ send msg, options | |
+ when Module then | |
+ recv = mod_or_meth | |
+ next unless recv.respond_to? :minitest_plugin_init | |
+ recv.minitest_plugin_init options | |
+ else | |
+ raise ArgumentError, "blahblah %p" % [mod_or_meth] | |
+ end | |
end | |
end | |
@@ -187,9 +196,19 @@ | |
opts.separator "" | |
opts.separator "Known extensions: #{extensions.join(", ")}" | |
- extensions.each do |meth| | |
- msg = "plugin_#{meth}_options" | |
- send msg, opts, options if self.respond_to?(msg) | |
+ extensions.each do |mod_or_meth| | |
+ case mod_or_meth | |
+ when Symbol, String then | |
+ meth = mod_or_meth | |
+ msg = "plugin_#{meth}_options" | |
+ send msg, opts, options if respond_to?(msg) | |
+ when Module | |
+ recv = mod_or_meth | |
+ next unless recv.respond_to? :minitest_plugin_options | |
+ recv.minitest_plugin_options opts, options | |
+ else | |
+ raise ArgumentError, "blahblah %p" % [mod_or_meth] | |
+ end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment