ruby-changes:34315
From: nobu <ko1@a...>
Date: Tue, 10 Jun 2014 23:12:11 +0900 (JST)
Subject: [ruby-changes:34315] nobu:r46396 (trunk): bootstraptest/runner.rb: refine output
nobu 2014-06-10 23:11:57 +0900 (Tue, 10 Jun 2014) New Revision: 46396 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46396 Log: bootstraptest/runner.rb: refine output * bootstraptest/runner.rb (exec_test, show_progress): erase with white spaces, and adjust each results at same column. Modified files: trunk/bootstraptest/runner.rb Index: bootstraptest/runner.rb =================================================================== --- bootstraptest/runner.rb (revision 46395) +++ bootstraptest/runner.rb (revision 46396) @@ -140,9 +140,8 @@ End https://github.com/ruby/ruby/blob/trunk/bootstraptest/runner.rb#L140 @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 https://github.com/ruby/ruby/blob/trunk/bootstraptest/runner.rb#L162 } 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 = '') https://github.com/ruby/ruby/blob/trunk/bootstraptest/runner.rb#L243 $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 https://github.com/ruby/ruby/blob/trunk/bootstraptest/runner.rb#L465 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/