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
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 "./runtime"
|
||||||
require "./totals"
|
require "./totals"
|
||||||
|
|
||||||
|
@ -9,30 +8,17 @@ module Spectator::Formatting::Components
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(io)
|
def to_s(io)
|
||||||
timing_line(io)
|
runtime(io)
|
||||||
totals_line(io)
|
totals(io)
|
||||||
|
|
||||||
unless (failures = @report.failures).empty?
|
|
||||||
io.puts
|
|
||||||
failures_block(io, failures)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private def timing_line(io)
|
private def runtime(io)
|
||||||
io << "Finished in "
|
io << "Finished in "
|
||||||
io.puts Runtime.new(@report.runtime)
|
io.puts Runtime.new(@report.runtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
private def totals_line(io)
|
private def totals(io)
|
||||||
io.puts Totals.colorize(@report.counts)
|
io.puts Totals.colorize(@report.counts)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,12 @@ module Spectator::Formatting
|
||||||
# Invoked after testing completes with summarized information from the test suite.
|
# Invoked after testing completes with summarized information from the test suite.
|
||||||
# Called after `#dump_failures` and before `#dump_profile`.
|
# Called after `#dump_failures` and before `#dump_profile`.
|
||||||
def dump_summary(notification)
|
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
|
end
|
||||||
|
|
||||||
# Invoked after testing completes with profiling information.
|
# Invoked after testing completes with profiling information.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue