diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-27 02:01:57 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-27 02:01:57 +0000 |
commit | 0e13879af65b5167cf670c0eeba9de8208edc3be (patch) | |
tree | d8deb49b267426c4bf9f6b439131f0a3ac1d7c29 /test | |
parent | 202fbaccf53df538cfbd89561c107abe5392ba54 (diff) | |
download | ruby-0e13879af65b5167cf670c0eeba9de8208edc3be.tar.gz |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/test/unit.rb | 24 |
1 files changed, 11 insertions, 13 deletions
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) |