summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-30 01:24:08 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-30 01:24:08 +0000
commit2f76e6d34c899d81f5c42e3b1e481c9e506a937a (patch)
tree2fe8d539c74a160df775c09bec01a74d25932701 /sample
parenta8f87d6d8d04d34ead8915ae350999c7875180ea (diff)
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
Diffstat (limited to 'sample')
-rwxr-xr-xsample/test.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/sample/test.rb b/sample/test.rb
index cefdef419e..3e73be93b6 100755
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -6,11 +6,23 @@ $ntest=0
$failed = 0
PROGRESS = Object.new
PROGRESS.instance_eval do
+ @color = nil
+ case ARGV[0]
+ when /\A--color(?:=(?:always|(auto)|(never)))?\z/
+ @color = (!$2 unless $1)
+ end
@count = 0
@rotator = %w[- \\ | /]
@bs = "\b" * @rotator[0].size
- @tty = STDERR.tty?
- if @tty and /mswin|mingw/ !~ RUBY_PLATFORM and /dumb/ !~ ENV["TERM"]
+ @tty = STDERR.tty? && /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"
@failed = "\e[#{ENV['FAILED_COLOR']||'31'}m"
@reset = "\e[m"