Skip to content

Commit

Permalink
bootstraptest: refine error output
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nobu committed Jul 5, 2012
1 parent fecdcc5 commit 6b801ac
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Thu Jul 5 15:14:50 2012 Nobuyoshi Nakada <[email protected]>

* 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 <[email protected]>

* test/net/http/test_httpresponses.rb: Add a test file for
Expand Down
38 changes: 25 additions & 13 deletions bootstraptest/runner.rb
Original file line number Diff line number Diff line change
@@ -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
# $Id$

Expand Down Expand Up @@ -123,21 +123,21 @@ def main

@progress = %w[- \\ | /]
@progress_bs = "\b" * @progress[0].size
@tty = !@verbose && $stderr.tty?
@tty = $stderr.tty?
case @color
when nil
@color = @tty && /dumb/ !~ ENV["TERM"]
when true
@tty = true
end
@tty &&= !@verbose
if @color
# dircolors-like style
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:]*)/)] : {}
@passed = "\e[#{colors["pass"] || "32"}m"
@failed = "\e[#{colors["fail"] || "31"}m"
@reset = "\e[m"
@erase = "\r\e[2K\r"
else
@passed = @failed = @reset = ""
@passed = @failed = @reset = @erase = ""
end
unless quiet
puts Time.now
Expand All @@ -164,16 +164,16 @@ def exec_test(pathes)
@errbuf = []
@location = nil
pathes.each do |path|
$stderr.print "#{File.basename(path)} "
$stderr.print @progress[@count % @progress.size] if @tty
@basename = File.basename(path)
$stderr.print @basename, " "
$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 "\r\e[2K\r" if @quiet
$stderr.print @erase if @quiet
else
$stderr.print "#{@progress_bs}#{@failed}FAIL #{@error-error}/#{@count-count}#{@reset}"
end
Expand All @@ -199,8 +199,10 @@ def exec_test(pathes)
def show_progress(message = '')
if @verbose
$stderr.print "\##{@count} #{@location} "
elsif @tty
$stderr.print @progress[@count % @progress.size]
end
faildesc = yield
faildesc, errout = with_stderr {yield}
if !faildesc
if @tty
$stderr.print "#{@progress_bs}#{@progress[@count % @progress.size]}"
Expand All @@ -209,9 +211,15 @@ def show_progress(message = '')
end
$stderr.puts if @verbose
else
$stderr.print 'F'
$stderr.print "#{@failed}F#{@reset}"
$stderr.puts if @verbose
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
rescue Interrupt
raise Interrupt
Expand All @@ -223,9 +231,8 @@ def show_progress(message = '')

def assert_check(testsrc, message = '', opt = '')
show_progress(message) {
result, errout = with_stderr {get_result_string(testsrc, opt)}
result = get_result_string(testsrc, opt)
check_coredump
error "stderr output is not empty\n", adjust_indent(errout) unless errout.empty?
yield(result)
}
end
Expand Down Expand Up @@ -425,7 +432,12 @@ def newtest
end

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
end

Expand Down

0 comments on commit 6b801ac

Please sign in to comment.