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

test/unit: return the cursor

* test/lib/test/unit.rb (update_status): keep the cursor to the
  beginning of the line for each update, so that unexpected output
  like an error message will overwrite but not be concatenated to
  the status.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-03-02 07:03:22 +00:00
parent a2845a44f8
commit 61b9074ca6

View file

@ -536,13 +536,12 @@ module Test
@status_line_size = 0
end
def add_status(line, flush: true)
def add_status(line)
@status_line_size ||= 0
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
@ -617,9 +616,11 @@ module Test
count = @test_count.to_s(10).rjust(@total_tests.size)
del_status_line(false)
print(@passed_color)
add_status("[#{count}/#{@total_tests}]", flush: false)
add_status("[#{count}/#{@total_tests}]")
print(@reset_color)
add_status(" #{s}")
$stdout.print "\r" if @options[:job_status] == :replace
$stdout.flush
end
def _print(s); $stdout.print(s); end