Skip to content

Commit ebb468c

Browse files
committed
+ Added "did you mean" output if your --name filter matches nothing. (tenderlove)
[git-p4: depot-paths = "//src/minitest/dev/": change = 14038]
1 parent ef83965 commit ebb468c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

lib/minitest.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,33 @@ def self.run args = []
164164
warn "Interrupted. Exiting..."
165165
end
166166
self.parallel_executor.shutdown
167+
168+
# might have been removed/replaced during init_plugins:
169+
summary = reporter.reporters.grep(SummaryReporter).first
170+
return empty_run! options if summary && summary.count == 0
171+
167172
reporter.report
168173

169174
reporter.passed?
170175
end
171176

177+
def self.empty_run! options # :nodoc:
178+
filter = options[:filter]
179+
180+
warn "Nothing ran for filter: %s" % [filter]
181+
182+
require "did_you_mean" # soft dependency, punt if it doesn't load
183+
184+
ms = Runnable.runnables.flat_map(&:runnable_methods)
185+
cs = DidYouMean::SpellChecker.new(dictionary: ms).correct filter
186+
187+
warn DidYouMean::Formatter.message_for cs unless cs.empty?
188+
rescue LoadError
189+
# do nothing
190+
ensure
191+
false
192+
end
193+
172194
##
173195
# Internal run method. Responsible for telling all Runnable
174196
# sub-classes to run.

0 commit comments

Comments
 (0)