UI improvements.

This commit is contained in:
Luka Vandervelden 2020-11-24 00:26:14 +01:00
parent 58be7c3d33
commit 737f34eb55

View File

@ -1,5 +1,6 @@
require "tap" require "tap"
require "option_parser" require "option_parser"
require "colorize"
class Storage class Storage
def initialize(@root : String = "storage") def initialize(@root : String = "storage")
@ -43,10 +44,13 @@ class Storage
end end
end end
Colorize.on_tty_only!
args = Array(String).new args = Array(String).new
show_projects = [] of String show_projects = [] of String
show_environments = [] of String show_environments = [] of String
show_revisions = [] of String show_revisions = [] of String
show_as_summary = true
OptionParser.parse! do |parser| OptionParser.parse! do |parser|
parser.banner = "usage: tap-aggregator <command> [options]" parser.banner = "usage: tap-aggregator <command> [options]"
@ -68,6 +72,10 @@ OptionParser.parse! do |parser|
show_revisions << id show_revisions << id
end end
parser.on("-v", "--verbose", "Prints all data instead of just summaries.") do
show_as_summary = false
end
parser.invalid_option do |flag| parser.invalid_option do |flag|
STDERR.puts "ERROR: #{flag} is not a valid option." STDERR.puts "ERROR: #{flag} is not a valid option."
STDERR.puts parser STDERR.puts parser
@ -128,9 +136,30 @@ when "show"
end end
results.each do |revision, timestamp, suite| results.each do |revision, timestamp, suite|
puts "#{project}, #{environment}, #{revision} (#{timestamp}) [ #{suite.size} tests ]" # FIXME: Only extract most recent revision if show_as_summary.
suite.each do |test| summary = suite.summary
puts " -> #{test.id} #{test.status} #{test.title}" 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 end
end end