1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

bootstraptest/runner.rb: refine output

* bootstraptest/runner.rb (exec_test, show_progress): erase with
  white spaces, and adjust each results at same column.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-06-10 14:11:57 +00:00
parent 26848ef8ff
commit 2c9c6271e8

View file

@ -140,9 +140,8 @@ End
@passed = "\e[#{colors["pass"] || "32"}m"
@failed = "\e[#{colors["fail"] || "31"}m"
@reset = "\e[m"
@erase = "\r\e[2K\r"
else
@passed = @failed = @reset = @erase = ""
@passed = @failed = @reset = ""
end
unless quiet
puts Time.now
@ -163,28 +162,44 @@ End
}
end
def erase(e = true)
if e and @columns > 0
"\r#{" "*@columns}\r"
else
""
end
end
def exec_test(pathes)
@count = 0
@error = 0
@errbuf = []
@location = nil
@columns = 0
@width = pathes.map {|path| File.basename(path).size}.max + 2
pathes.each do |path|
@basename = File.basename(path)
$stderr.print @basename, " "
$stderr.printf("%s%-*s ", erase(@quiet), @width, @basename)
$stderr.flush
@columns = @width + 1
$stderr.puts if @verbose
count = @count
error = @error
load File.expand_path(path)
if @tty
if @error == error
$stderr.print "#{@progress_bs}#{@passed}PASS #{@count-count}#{@reset}"
$stderr.print @erase if @quiet
msg = "PASS #{@count-count}"
@columns += msg.size - 1
$stderr.print "#{@progress_bs}#{@passed}#{msg}#{@reset}"
else
$stderr.print "#{@progress_bs}#{@failed}FAIL #{@error-error}/#{@count-count}#{@reset}"
msg = "FAIL #{@error-error}/#{@count-count}"
$stderr.print "#{@progress_bs}#{@failed}#{msg}#{@reset}"
@columns = 0
end
end
$stderr.puts unless @quiet and @tty
$stderr.puts unless @quiet and @tty and @error == error
end
$stderr.print(erase) if @quiet
if @error == 0
if @count == 0
$stderr.puts "No tests, no problem"
@ -228,7 +243,7 @@ def show_progress(message = '')
$stderr.print "#{@failed}stderr output is not empty#{@reset}\n", adjust_indent(errout)
end
if @tty and !@verbose
$stderr.print @basename, " ", @progress[@count % @progress.size]
$stderr.printf("%-*s%s", @width, @basename, @progress[@count % @progress.size])
end
end
rescue Interrupt
@ -450,7 +465,7 @@ end
def error(msg, additional_message)
msg = "#{@failed}\##{@count} #{@location}#{@reset}: #{msg} #{additional_message}"
if @tty
$stderr.puts "#{@erase}#{msg}"
$stderr.puts "#{erase}#{msg}"
else
@errbuf.push msg
end