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

test: reduce output if succeded

* bootstraptest/runner.rb (exec_test): reduce output if succeded.
* sample/test.rb (PROGRESS.finish): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-06-26 07:46:26 +00:00
parent ffa20cf154
commit 5605afa5e2
2 changed files with 10 additions and 3 deletions

View file

@ -62,6 +62,7 @@ def main
@verbose = false @verbose = false
$stress = false $stress = false
@color = nil @color = nil
@quiet = false
dir = nil dir = nil
quiet = false quiet = false
tests = nil tests = nil
@ -88,6 +89,7 @@ def main
true true
when /\A(-q|--q(uiet))\z/ when /\A(-q|--q(uiet))\z/
quiet = true quiet = true
@quiet = true
true true
when /\A(-v|--v(erbose))\z/ when /\A(-v|--v(erbose))\z/
@verbose = true @verbose = true
@ -162,7 +164,7 @@ def exec_test(pathes)
@errbuf = [] @errbuf = []
@location = nil @location = nil
pathes.each do |path| pathes.each do |path|
$stderr.print "\n#{File.basename(path)} " $stderr.print "#{File.basename(path)} "
$stderr.print @progress[@count % @progress.size] if @tty $stderr.print @progress[@count % @progress.size] if @tty
$stderr.puts if @verbose $stderr.puts if @verbose
count = @count count = @count
@ -171,12 +173,13 @@ 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
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
end end
$stderr.puts unless @quiet
end end
$stderr.puts
if @error == 0 if @error == 0
if @count == 0 if @count == 0
$stderr.puts "No tests, no problem" $stderr.puts "No tests, no problem"

View file

@ -7,10 +7,13 @@ $failed = 0
PROGRESS = Object.new PROGRESS = Object.new
PROGRESS.instance_eval do PROGRESS.instance_eval do
@color = nil @color = nil
@quiet = nil
case ARGV[0] case ARGV[0]
when /\A--color(?:=(?:always|(auto)|(never)|(.*)))?\z/ when /\A--color(?:=(?:always|(auto)|(never)|(.*)))?\z/
warn "unknown --color argument: #$3" if $3 warn "unknown --color argument: #$3" if $3
@color = $1 ? nil : !$2 @color = $1 ? nil : !$2
when /\A-(q|-quiet)\z/
@quiet = true
end end
@count = 0 @count = 0
@rotator = %w[- \\ | /] @rotator = %w[- \\ | /]
@ -46,6 +49,7 @@ PROGRESS.instance_eval do
end end
def self.finish def self.finish
STDERR.print "#{@bs}#{' ' * @bs.size}#{@bs}#{@passed}#{@ok ? 'OK' : ''} #{$testnum}#{@reset}" STDERR.print "#{@bs}#{' ' * @bs.size}#{@bs}#{@passed}#{@ok ? 'OK' : ''} #{$testnum}#{@reset}"
STDERR.print @quiet ? "\r\e[2K\r" : "\n"
end end
else else
def self.pass def self.pass
@ -65,7 +69,7 @@ def test_check(what)
unless $ntest.zero? unless $ntest.zero?
PROGRESS.finish PROGRESS.finish
end end
STDERR.print "\nsample/test.rb:#{what} " STDERR.print "sample/test.rb:#{what} "
PROGRESS.init PROGRESS.init
$what = what $what = what
$testnum = 0 $testnum = 0