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

respect --quiet option for btest

Do not print anymore except errors.
This commit is contained in:
Koichi Sasada 2022-01-21 17:38:11 +09:00
parent a15c50d6a1
commit 5e3a320218
2 changed files with 19 additions and 9 deletions

View file

@ -187,8 +187,10 @@ def exec_test(pathes)
@width = pathes.map {|path| File.basename(path).size}.max + 2 @width = pathes.map {|path| File.basename(path).size}.max + 2
pathes.each do |path| pathes.each do |path|
@basename = File.basename(path) @basename = File.basename(path)
unless @quiet
$stderr.printf("%s%-*s ", erase(@quiet), @width, @basename) $stderr.printf("%s%-*s ", erase(@quiet), @width, @basename)
$stderr.flush $stderr.flush
end
@columns = @width + 1 @columns = @width + 1
$stderr.puts if @verbose $stderr.puts if @verbose
count = @count count = @count
@ -198,14 +200,14 @@ def exec_test(pathes)
if @error == error if @error == error
msg = "PASS #{@count-count}" msg = "PASS #{@count-count}"
@columns += msg.size - 1 @columns += msg.size - 1
$stderr.print "#{@progress_bs}#{@passed}#{msg}#{@reset}" $stderr.print "#{@progress_bs}#{@passed}#{msg}#{@reset}" unless @quiet
else else
msg = "FAIL #{@error-error}/#{@count-count}" msg = "FAIL #{@error-error}/#{@count-count}"
$stderr.print "#{@progress_bs}#{@failed}#{msg}#{@reset}" $stderr.print "#{@progress_bs}#{@failed}#{msg}#{@reset}"
@columns = 0 @columns = 0
end end
end end
$stderr.puts unless @quiet and @tty and @error == error $stderr.puts if !@quiet and (@tty or @error == error)
end end
$stderr.print(erase) if @quiet $stderr.print(erase) if @quiet
@errbuf.each do |msg| @errbuf.each do |msg|
@ -213,10 +215,14 @@ def exec_test(pathes)
end end
if @error == 0 if @error == 0
if @count == 0 if @count == 0
$stderr.puts "No tests, no problem" $stderr.puts "No tests, no problem" unless @quiet
else
if @quiet
$stdout.puts "#{@passed}PASS#{@reset} all #{@count} tests"
else else
$stderr.puts "#{@passed}PASS#{@reset} all #{@count} tests" $stderr.puts "#{@passed}PASS#{@reset} all #{@count} tests"
end end
end
exit true exit true
else else
$stderr.puts "#{@failed}FAIL#{@reset} #{@error}/#{@count} tests failed" $stderr.puts "#{@failed}FAIL#{@reset} #{@error}/#{@count} tests failed"
@ -225,7 +231,9 @@ def exec_test(pathes)
end end
def show_progress(message = '') def show_progress(message = '')
if @verbose if @quiet
# do nothing
elsif @verbose
$stderr.print "\##{@count} #{@location} " $stderr.print "\##{@count} #{@location} "
elsif @tty elsif @tty
$stderr.print "#{@progress_bs}#{@progress[@count % @progress.size]}" $stderr.print "#{@progress_bs}#{@progress[@count % @progress.size]}"
@ -234,7 +242,9 @@ def show_progress(message = '')
faildesc, errout = with_stderr {yield} faildesc, errout = with_stderr {yield}
t = Time.now - t if @verbose t = Time.now - t if @verbose
if !faildesc if !faildesc
if @tty if @quiet
# do nothing
elsif @tty
$stderr.print "#{@progress_bs}#{@progress[@count % @progress.size]}" $stderr.print "#{@progress_bs}#{@progress[@count % @progress.size]}"
elsif @verbose elsif @verbose
$stderr.printf(". %.3f\n", t) $stderr.printf(". %.3f\n", t)

View file

@ -10,7 +10,7 @@ show_limit %q{
puts "Fiber count: #{fibers.count} (#{error})" puts "Fiber count: #{fibers.count} (#{error})"
break break
end while true end while true
} } unless @quiet
assert_equal %q{ok}, %q{ assert_equal %q{ok}, %q{
Fiber.new{ Fiber.new{