Skip to content

Instantly share code, notes, and snippets.

@zenspider
Created January 26, 2024 23:11
Show Gist options
  • Save zenspider/6e7aee35336c01ace98d6f66c8338ae7 to your computer and use it in GitHub Desktop.
Save zenspider/6e7aee35336c01ace98d6f66c8338ae7 to your computer and use it in GitHub Desktop.
diff -r old/lib/minitest.rb new/lib/minitest.rb
--- old/lib/minitest.rb
+++ new/lib/minitest.rb
@@ -164,11 +164,33 @@
warn "Interrupted. Exiting..."
end
self.parallel_executor.shutdown
+
+ # might have been removed/replaced during init_plugins:
+ summary = reporter.reporters.grep(SummaryReporter).first
+ return empty_run! options if summary && summary.count == 0
+
reporter.report
reporter.passed?
end
+ def self.empty_run! options # :nodoc:
+ filter = options[:filter]
+
+ warn "Nothing ran for filter: %s" % [filter]
+
+ require "did_you_mean" # soft dependency, punt if it doesn't load
+
+ ms = Runnable.runnables.flat_map(&:runnable_methods)
+ cs = DidYouMean::SpellChecker.new(dictionary: ms).correct filter
+
+ warn DidYouMean::Formatter.message_for cs unless cs.empty?
+ rescue LoadError
+ # do nothing
+ ensure
+ false
+ end
+
##
# Internal run method. Responsible for telling all Runnable
# sub-classes to run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment