UI improvements.
parent
58be7c3d33
commit
737f34eb55
35
src/main.cr
35
src/main.cr
|
@ -1,5 +1,6 @@
|
|||
require "tap"
|
||||
require "option_parser"
|
||||
require "colorize"
|
||||
|
||||
class Storage
|
||||
def initialize(@root : String = "storage")
|
||||
|
@ -43,10 +44,13 @@ class Storage
|
|||
end
|
||||
end
|
||||
|
||||
Colorize.on_tty_only!
|
||||
|
||||
args = Array(String).new
|
||||
show_projects = [] of String
|
||||
show_environments = [] of String
|
||||
show_revisions = [] of String
|
||||
show_as_summary = true
|
||||
|
||||
OptionParser.parse! do |parser|
|
||||
parser.banner = "usage: tap-aggregator <command> [options]"
|
||||
|
@ -68,6 +72,10 @@ OptionParser.parse! do |parser|
|
|||
show_revisions << id
|
||||
end
|
||||
|
||||
parser.on("-v", "--verbose", "Prints all data instead of just summaries.") do
|
||||
show_as_summary = false
|
||||
end
|
||||
|
||||
parser.invalid_option do |flag|
|
||||
STDERR.puts "ERROR: #{flag} is not a valid option."
|
||||
STDERR.puts parser
|
||||
|
@ -128,9 +136,30 @@ when "show"
|
|||
end
|
||||
|
||||
results.each do |revision, timestamp, suite|
|
||||
puts "#{project}, #{environment}, #{revision} (#{timestamp}) [ #{suite.size} tests ]"
|
||||
suite.each do |test|
|
||||
puts " -> #{test.id} #{test.status} #{test.title}"
|
||||
# FIXME: Only extract most recent revision if show_as_summary.
|
||||
summary = suite.summary
|
||||
number_ok = summary.tests_passed.size
|
||||
number_failed = summary.tests_failed.size
|
||||
|
||||
# This prints the header, or summary line of a test suite.
|
||||
STDOUT << ("%-15s" % project).colorize(:white).bright
|
||||
STDOUT << " (#{environment}) r=#{revision}, "
|
||||
|
||||
STDOUT << "#{number_ok} ok".colorize(:green).bright
|
||||
STDOUT << ", "
|
||||
STDOUT << "#{number_failed} not ok".colorize(:red).bright
|
||||
STDOUT << "\n"
|
||||
|
||||
if !show_as_summary
|
||||
suite.each do |test|
|
||||
# This prints a single TAP test entry.
|
||||
STDOUT << " -> "
|
||||
STDOUT << ("%3s" % test.id).colorize(:cyan)
|
||||
STDOUT << (" %6s " % test.status.to_s).colorize(:green)
|
||||
STDOUT << test.title.colorize(:white)
|
||||
STDOUT << "\n"
|
||||
STDOUT.flush
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue