mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Move failure command it's own type
This commit is contained in:
parent
e92b1dc466
commit
487726ea54
2 changed files with 23 additions and 6 deletions
19
src/spectator/formatters/failure_command.cr
Normal file
19
src/spectator/formatters/failure_command.cr
Normal file
|
@ -0,0 +1,19 @@
|
|||
module Spectator::Formatters
|
||||
# Produces a stringified command to run a failed test.
|
||||
private struct FailureCommand
|
||||
# Creates the failure command.
|
||||
def initialize(@example : Example)
|
||||
end
|
||||
|
||||
# Appends the command to the output.
|
||||
def to_s(io)
|
||||
io << "crystal spec "
|
||||
io << @example.source
|
||||
end
|
||||
|
||||
# Colorizes the command instance based on the result.
|
||||
def self.color(result)
|
||||
result.call(Color) { new(result.example) }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,12 +10,11 @@ module Spectator::Formatters
|
|||
# A block describing each failure is displayed.
|
||||
# At the end, the totals and runtime are printed.
|
||||
def end_suite(report)
|
||||
failed = report.failed_count > 0
|
||||
@io.puts
|
||||
@io.puts
|
||||
failures(report.failures) if failed
|
||||
failures(report.failures) if report.failed?
|
||||
stats(report)
|
||||
failure_commands(report.failures) if failed
|
||||
failure_commands(report.failures) if report.failed?
|
||||
end
|
||||
|
||||
# Produces the failure section of the summary.
|
||||
|
@ -44,10 +43,9 @@ module Spectator::Formatters
|
|||
@io.puts "Failed examples:"
|
||||
@io.puts
|
||||
failures.each do |result|
|
||||
@io.print "crystal spec "
|
||||
result.example.source.to_s(@io)
|
||||
@io << FailureCommand.color(result)
|
||||
@io << ' '
|
||||
@io.puts Comment.color("TODO")
|
||||
@io.puts Comment.color(result.example)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue