From 9c55cb2e9ebbe5366f3f1e7e3c63d64f860fc0a7 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 27 Feb 2016 02:01:57 +0000 Subject: test/unit: refine output in verbose mode * test/lib/test/unit.rb (Test::Unit::StatusLine#_prepare_run): add StatusLine::Output even if job_status is not replace, to filter extra outputs and newlines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/lib/test/unit.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'test/lib') diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb index 0191a93089..312cacb8d0 100644 --- a/test/lib/test/unit.rb +++ b/test/lib/test/unit.rb @@ -522,30 +522,27 @@ module Test def del_status_line(flush = true) @status_line_size ||= 0 - unless @options[:job_status] == :replace - $stdout.puts - return + if @options[:job_status] == :replace + $stdout.print "\r"+" "*@status_line_size+"\r" + else + $stdout.puts if @status_line_size > 0 end - print "\r"+" "*@status_line_size+"\r" $stdout.flush if flush @status_line_size = 0 end def add_status(line, flush: true) - unless @options[:job_status] == :replace - print(line) - return - end @status_line_size ||= 0 - line = line[0...(terminal_width-@status_line_size)] + if @options[:job_status] == :replace + line = line[0...(terminal_width-@status_line_size)] + end print line $stdout.flush if flush @status_line_size += line.size end def jobs_status - return unless @options[:job_status] - puts "" unless @options[:verbose] or @options[:job_status] == :replace + return if !@options[:job_status] or @options[:verbose] status_line = @workers.map(&:to_s).join(" ") update_status(status_line) or (puts; nil) end @@ -587,8 +584,8 @@ module Test end if color or @options[:job_status] == :replace @verbose = !options[:parallel] - @output = Output.new(self) end + @output = Output.new(self) if /\A\/(.*)\/\z/ =~ (filter = options[:filter]) filter = Regexp.new($1) end @@ -604,12 +601,13 @@ module Test def new_test(s) @test_count += 1 + return if !@options[:job_status] or @options[:verbose] update_status(s) end def update_status(s) count = @test_count.to_s(10).rjust(@total_tests.size) - del_status_line(false) if @options[:job_status] == :replace + del_status_line(false) print(@passed_color) add_status("[#{count}/#{@total_tests}]", flush: false) print(@reset_color) -- cgit v1.2.3