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

bootstraptest: refine error output

* bootstraptest/runner.rb (show_progress): refine error output. do not
  count non-empty error message, but just warn.
* bootstraptest/runner.rb (error): show errors immediately if tty.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-07-05 06:15:00 +00:00
parent fecdcc51ea
commit 6b801ac9f8
2 changed files with 32 additions and 13 deletions

View file

@ -1,3 +1,10 @@
Thu Jul 5 15:14:50 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bootstraptest/runner.rb (show_progress): refine error output. do not
count non-empty error message, but just warn.
* bootstraptest/runner.rb (error): show errors immediately if tty.
Thu Jul 5 12:28:11 2012 Akinori MUSHA <knu@iDaemons.org> Thu Jul 5 12:28:11 2012 Akinori MUSHA <knu@iDaemons.org>
* test/net/http/test_httpresponses.rb: Add a test file for * test/net/http/test_httpresponses.rb: Add a test file for

View file

@ -1,4 +1,4 @@
"exec" "${RUBY-ruby}" "-x" "$0" "$@"; true # -*- mode: ruby; coding: utf-8 -*- "exec" "${RUBY-ruby}" "-x" "$0" "$@" || true # -*- mode: ruby; coding: utf-8 -*-
#!./ruby #!./ruby
# $Id$ # $Id$
@ -123,21 +123,21 @@ End
@progress = %w[- \\ | /] @progress = %w[- \\ | /]
@progress_bs = "\b" * @progress[0].size @progress_bs = "\b" * @progress[0].size
@tty = !@verbose && $stderr.tty? @tty = $stderr.tty?
case @color case @color
when nil when nil
@color = @tty && /dumb/ !~ ENV["TERM"] @color = @tty && /dumb/ !~ ENV["TERM"]
when true
@tty = true
end end
@tty &&= !@verbose
if @color if @color
# dircolors-like style # dircolors-like style
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:]*)/)] : {} colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:]*)/)] : {}
@passed = "\e[#{colors["pass"] || "32"}m" @passed = "\e[#{colors["pass"] || "32"}m"
@failed = "\e[#{colors["fail"] || "31"}m" @failed = "\e[#{colors["fail"] || "31"}m"
@reset = "\e[m" @reset = "\e[m"
@erase = "\r\e[2K\r"
else else
@passed = @failed = @reset = "" @passed = @failed = @reset = @erase = ""
end end
unless quiet unless quiet
puts Time.now puts Time.now
@ -164,8 +164,8 @@ def exec_test(pathes)
@errbuf = [] @errbuf = []
@location = nil @location = nil
pathes.each do |path| pathes.each do |path|
$stderr.print "#{File.basename(path)} " @basename = File.basename(path)
$stderr.print @progress[@count % @progress.size] if @tty $stderr.print @basename, " "
$stderr.puts if @verbose $stderr.puts if @verbose
count = @count count = @count
error = @error error = @error
@ -173,7 +173,7 @@ def exec_test(pathes)
if @tty if @tty
if @error == error if @error == error
$stderr.print "#{@progress_bs}#{@passed}PASS #{@count-count}#{@reset}" $stderr.print "#{@progress_bs}#{@passed}PASS #{@count-count}#{@reset}"
$stderr.print "\r\e[2K\r" if @quiet $stderr.print @erase if @quiet
else else
$stderr.print "#{@progress_bs}#{@failed}FAIL #{@error-error}/#{@count-count}#{@reset}" $stderr.print "#{@progress_bs}#{@failed}FAIL #{@error-error}/#{@count-count}#{@reset}"
end end
@ -199,8 +199,10 @@ end
def show_progress(message = '') def show_progress(message = '')
if @verbose if @verbose
$stderr.print "\##{@count} #{@location} " $stderr.print "\##{@count} #{@location} "
elsif @tty
$stderr.print @progress[@count % @progress.size]
end end
faildesc = yield faildesc, errout = with_stderr {yield}
if !faildesc if !faildesc
if @tty if @tty
$stderr.print "#{@progress_bs}#{@progress[@count % @progress.size]}" $stderr.print "#{@progress_bs}#{@progress[@count % @progress.size]}"
@ -209,9 +211,15 @@ def show_progress(message = '')
end end
$stderr.puts if @verbose $stderr.puts if @verbose
else else
$stderr.print 'F' $stderr.print "#{@failed}F#{@reset}"
$stderr.puts if @verbose $stderr.puts if @verbose
error faildesc, message error faildesc, message
unless errout.empty?
$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]
end
end end
rescue Interrupt rescue Interrupt
raise Interrupt raise Interrupt
@ -223,9 +231,8 @@ end
def assert_check(testsrc, message = '', opt = '') def assert_check(testsrc, message = '', opt = '')
show_progress(message) { show_progress(message) {
result, errout = with_stderr {get_result_string(testsrc, opt)} result = get_result_string(testsrc, opt)
check_coredump check_coredump
error "stderr output is not empty\n", adjust_indent(errout) unless errout.empty?
yield(result) yield(result)
} }
end end
@ -425,7 +432,12 @@ def newtest
end end
def error(msg, additional_message) def error(msg, additional_message)
@errbuf.push "\##{@count} #{@location}: #{msg} #{additional_message}" msg = "#{@failed}\##{@count} #{@location}#{@reset}: #{msg} #{additional_message}"
if @tty
$stderr.puts "#{@erase}#{msg}"
else
@errbuf.push msg
end
@error += 1 @error += 1
end end