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

* lib/test/unit.rb (Test::Unit::Runner#jobs_status): io/console may

not be available. use 80 as the last resort if IO#winsize and
  COLUMNS are unavailable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-04-14 13:48:09 +00:00
parent 146bedd6c4
commit 3d41f4df43
2 changed files with 15 additions and 7 deletions

View file

@ -1,4 +1,8 @@
Thu Apr 14 22:47:58 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
Thu Apr 14 22:48:03 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit.rb (Test::Unit::Runner#jobs_status): io/console may
not be available. use 80 as the last resort if IO#winsize and
COLUMNS are unavailable.
* lib/test/unit.rb (Test::Unit::Runner::Worker#died): rename using a
verb.

View file

@ -4,7 +4,6 @@ require 'minitest/unit'
require 'test/unit/assertions'
require 'test/unit/testcase'
require 'optparse'
require 'io/console'
module Test
module Unit
@ -351,22 +350,27 @@ module Test
return unless @opts[:job_status]
puts "" unless @opts[:verbose]
status_line = @workers.map(&:to_s).join(" ")
if @opts[:job_status] == :replace
@terminal_width ||= $stdout.winsize[1] || ENV["COLUMNS"].to_i || 80
if @opts[:job_status] == :replace and $stdout.tty?
@terminal_width ||=
begin
require 'io/console'
$stdout.winsize[1]
rescue LoadError, NoMethodError
ENV["COLUMNS"].to_i.nonzero? || 80
end
@jstr_size ||= 0
del_jobs_status
$stdout.flush
print status_line[0...@terminal_width]
$stdout.flush
@jstr_size = status_line.size > @terminal_width ? \
@terminal_width : status_line.size
@jstr_size = [status_line.size, @terminal_width].min
else
puts status_line
end
end
def del_jobs_status
return unless @opts[:job_status] == :replace && @jstr_size
return unless @opts[:job_status] == :replace && @jstr_size.nonzero?
print "\r"+" "*@jstr_size+"\r"
end