color option
* bootstraptest/runner.rb, sample/test.rb: add --color option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a8f87d6d8d
commit
2f76e6d34c
@ -61,6 +61,7 @@ def main
|
|||||||
@ruby = File.expand_path('miniruby')
|
@ruby = File.expand_path('miniruby')
|
||||||
@verbose = false
|
@verbose = false
|
||||||
$stress = false
|
$stress = false
|
||||||
|
@color = nil
|
||||||
dir = nil
|
dir = nil
|
||||||
quiet = false
|
quiet = false
|
||||||
tests = nil
|
tests = nil
|
||||||
@ -81,6 +82,9 @@ def main
|
|||||||
true
|
true
|
||||||
when /\A(--stress|-s)/
|
when /\A(--stress|-s)/
|
||||||
$stress = true
|
$stress = true
|
||||||
|
when /\A--color(?:=(?:always|(auto)|(never)))?\z/
|
||||||
|
@color = (!$2 unless $1)
|
||||||
|
true
|
||||||
when /\A(-q|--q(uiet))\z/
|
when /\A(-q|--q(uiet))\z/
|
||||||
quiet = true
|
quiet = true
|
||||||
true
|
true
|
||||||
@ -113,7 +117,14 @@ End
|
|||||||
@progress = %w[- \\ | /]
|
@progress = %w[- \\ | /]
|
||||||
@progress_bs = "\b" * @progress[0].size
|
@progress_bs = "\b" * @progress[0].size
|
||||||
@tty = !@verbose && $stderr.tty?
|
@tty = !@verbose && $stderr.tty?
|
||||||
if @tty and /mswin|mingw/ !~ RUBY_PLATFORM and /dumb/ !~ ENV["TERM"]
|
case @color
|
||||||
|
when nil
|
||||||
|
@color = @tty && /dumb/ !~ ENV["TERM"]
|
||||||
|
@color &= /mswin|mingw/ !~ RUBY_PLATFORM
|
||||||
|
when true
|
||||||
|
@tty = true
|
||||||
|
end
|
||||||
|
if @color
|
||||||
@passed = "\e[#{ENV['PASSED_COLOR']||'32'}m"
|
@passed = "\e[#{ENV['PASSED_COLOR']||'32'}m"
|
||||||
@failed = "\e[#{ENV['FAILED_COLOR']||'31'}m"
|
@failed = "\e[#{ENV['FAILED_COLOR']||'31'}m"
|
||||||
@reset = "\e[m"
|
@reset = "\e[m"
|
||||||
|
@ -6,11 +6,23 @@ $ntest=0
|
|||||||
$failed = 0
|
$failed = 0
|
||||||
PROGRESS = Object.new
|
PROGRESS = Object.new
|
||||||
PROGRESS.instance_eval do
|
PROGRESS.instance_eval do
|
||||||
|
@color = nil
|
||||||
|
case ARGV[0]
|
||||||
|
when /\A--color(?:=(?:always|(auto)|(never)))?\z/
|
||||||
|
@color = (!$2 unless $1)
|
||||||
|
end
|
||||||
@count = 0
|
@count = 0
|
||||||
@rotator = %w[- \\ | /]
|
@rotator = %w[- \\ | /]
|
||||||
@bs = "\b" * @rotator[0].size
|
@bs = "\b" * @rotator[0].size
|
||||||
@tty = STDERR.tty?
|
@tty = STDERR.tty? && /dumb/ !~ ENV["TERM"]
|
||||||
if @tty and /mswin|mingw/ !~ RUBY_PLATFORM and /dumb/ !~ ENV["TERM"]
|
@tty &&= /mswin|mingw/ !~ RUBY_PLATFORM
|
||||||
|
case @color
|
||||||
|
when nil
|
||||||
|
@color = @tty
|
||||||
|
when true
|
||||||
|
@tty = true
|
||||||
|
end
|
||||||
|
if @color
|
||||||
@passed = "\e[#{ENV['PASSED_COLOR']||'32'}m"
|
@passed = "\e[#{ENV['PASSED_COLOR']||'32'}m"
|
||||||
@failed = "\e[#{ENV['FAILED_COLOR']||'31'}m"
|
@failed = "\e[#{ENV['FAILED_COLOR']||'31'}m"
|
||||||
@reset = "\e[m"
|
@reset = "\e[m"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user