mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Move failure command list to its own component
This commit is contained in:
parent
2316377c6e
commit
ed3ad662d2
3 changed files with 26 additions and 19 deletions
src/spectator/formatting
16
src/spectator/formatting/components/failure_command_list.cr
Normal file
16
src/spectator/formatting/components/failure_command_list.cr
Normal file
|
@ -0,0 +1,16 @@
|
|||
require "./example_command"
|
||||
|
||||
module Spectator::Formatting::Components
|
||||
struct FailureCommandList
|
||||
def initialize(@failures : Enumerable(Example))
|
||||
end
|
||||
|
||||
def to_s(io)
|
||||
io.puts "Failed examples:"
|
||||
io.puts
|
||||
@failures.each do |failure|
|
||||
io.puts ExampleCommand.new(failure).colorize(:red)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,3 @@
|
|||
require "./example_command"
|
||||
require "./runtime"
|
||||
require "./totals"
|
||||
|
||||
|
@ -9,30 +8,17 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
|
||||
def to_s(io)
|
||||
timing_line(io)
|
||||
totals_line(io)
|
||||
|
||||
unless (failures = @report.failures).empty?
|
||||
io.puts
|
||||
failures_block(io, failures)
|
||||
end
|
||||
runtime(io)
|
||||
totals(io)
|
||||
end
|
||||
|
||||
private def timing_line(io)
|
||||
private def runtime(io)
|
||||
io << "Finished in "
|
||||
io.puts Runtime.new(@report.runtime)
|
||||
end
|
||||
|
||||
private def totals_line(io)
|
||||
private def totals(io)
|
||||
io.puts Totals.colorize(@report.counts)
|
||||
end
|
||||
|
||||
private def failures_block(io, failures)
|
||||
io.puts "Failed examples:"
|
||||
io.puts
|
||||
failures.each do |failure|
|
||||
io.puts ExampleCommand.new(failure).colorize(:red)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,12 @@ module Spectator::Formatting
|
|||
# Invoked after testing completes with summarized information from the test suite.
|
||||
# Called after `#dump_failures` and before `#dump_profile`.
|
||||
def dump_summary(notification)
|
||||
io.puts Components::Stats.new(notification.report)
|
||||
report = notification.report
|
||||
io.puts Components::Stats.new(report)
|
||||
|
||||
return if (failures = report.failures).empty?
|
||||
|
||||
io.puts Components::FailureCommandList.new(failures)
|
||||
end
|
||||
|
||||
# Invoked after testing completes with profiling information.
|
||||
|
|
Loading…
Reference in a new issue