Skip to content

Commit

Permalink
+ Added -S <CODES> option to skip reporting of certain types of output
Browse files Browse the repository at this point in the history
I use this when I need to focus on errors and ignore failures for a while.

[git-p4: depot-paths = "//src/minitest/dev/": change = 13273]
  • Loading branch information
zenspider committed Dec 5, 2021
1 parent a4fc58c commit 6570cec
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
8 changes: 8 additions & 0 deletions lib/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ def self.process_args args = [] # :nodoc:
options[:exclude] = a
end

opts.on "-S", "--skip CODES", String, "Skip reporting of certain types of results (eg E)." do |s|
options[:skip] = s.chars.to_a
end

unless extensions.empty?
opts.separator ""
opts.separator "Known extensions: #{extensions.join(", ")}"
Expand Down Expand Up @@ -786,7 +790,11 @@ def aggregated_results io # :nodoc:
filtered_results = results.dup
filtered_results.reject!(&:skipped?) unless options[:verbose]

skip = options[:skip] || []

filtered_results.each_with_index { |result, i|
next if skip.include? result.result_code

io.puts "\n%3d) %s" % [i+1, result]
}
io.puts
Expand Down
42 changes: 25 additions & 17 deletions test/minitest/test_minitest_reporter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "minitest/autorun"
require "minitest/metametameta"
require "forwardable"

class Runnable
def woot
Expand All @@ -16,21 +17,10 @@ def new_composite_reporter
reporter << Minitest::SummaryReporter.new(self.io)
reporter << Minitest::ProgressReporter.new(self.io)

def reporter.first
reporters.first
end

def reporter.results
first.results
end

def reporter.count
first.count
end

def reporter.assertions
first.assertions
end
# eg reporter.results -> reporters.first.results
reporter.extend Forwardable
reporter.delegate :first => :reporters
reporter.delegate %i[results count assertions options to_s] => :first

reporter
end
Expand Down Expand Up @@ -86,7 +76,25 @@ def skip_test
def test_to_s
r.record passing_test
r.record fail_test
assert_match "woot", r.first.to_s
assert_match "woot", r.to_s
end

def test_options_skip_F
r.options[:skip] = "F"

r.record passing_test
r.record fail_test

refute_match "woot", r.to_s
end

def test_options_skip_E
r.options[:skip] = "E"

r.record passing_test
r.record error_test

refute_match "RuntimeError: no", r.to_s
end

def test_passed_eh_empty
Expand Down Expand Up @@ -126,7 +134,7 @@ def test_passed_eh_skipped
end

def test_passed_eh_skipped_verbose
r.first.options[:verbose] = true
r.options[:verbose] = true

r.start
r.results << skip_test
Expand Down

0 comments on commit 6570cec

Please sign in to comment.