[前][次][番号順一覧][スレッド一覧]

ruby-changes:24044

From: nobu <ko1@a...>
Date: Fri, 15 Jun 2012 09:56:51 +0900 (JST)
Subject: [ruby-changes:24044] nobu:r36095 (trunk): test: TEST_COLORS

nobu	2012-06-15 09:56:39 +0900 (Fri, 15 Jun 2012)

  New Revision: 36095

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36095

  Log:
    test: TEST_COLORS
    
    * bootstraptest/runner.rb (main): customize colors by dircolors-like
      style environment variable TEST_COLORS.
    
    * lib/test/unit.rb (Test::Unit::Runner#_prepare_run): ditto.
    
    * sample/test.rb: ditto.

  Modified files:
    trunk/bootstraptest/runner.rb
    trunk/lib/test/unit.rb
    trunk/sample/test.rb

Index: bootstraptest/runner.rb
===================================================================
--- bootstraptest/runner.rb	(revision 36094)
+++ bootstraptest/runner.rb	(revision 36095)
@@ -127,8 +127,10 @@
     @tty = true
   end
   if @color
-    @passed = "\e[#{ENV['PASSED_COLOR']||'32'}m"
-    @failed = "\e[#{ENV['FAILED_COLOR']||'31'}m"
+    # dircolors-like style
+    colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w)=([^:]*)/)] : {}
+    @passed = "\e[#{colors["pass"] || "32"}m"
+    @failed = "\e[#{colors["fail"] || "31"}m"
     @reset = "\e[m"
   else
     @passed = @failed = @reset = ""
Index: sample/test.rb
===================================================================
--- sample/test.rb	(revision 36094)
+++ sample/test.rb	(revision 36095)
@@ -23,8 +23,10 @@
     @tty = true
   end
   if @color
-    @passed = "\e[#{ENV['PASSED_COLOR']||'32'}m"
-    @failed = "\e[#{ENV['FAILED_COLOR']||'31'}m"
+    # dircolors-like style
+    colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w)=([^:]*)/)] : {}
+    @passed = "\e[#{colors["pass"] || "32"}m"
+    @failed = "\e[#{colors["fail"] || "31"}m"
     @reset = "\e[m"
   else
     @passed = @failed = @reset = ""
Index: lib/test/unit.rb
===================================================================
--- lib/test/unit.rb	(revision 36094)
+++ lib/test/unit.rb	(revision 36095)
@@ -676,11 +676,13 @@
           color = false
         end
         if color
-          @passed_color = "\e[#{ENV['PASSED_COLOR']||'32'}m"
-          @failed_color = "\e[#{ENV['FAILED_COLOR']||'31'}m"
+          # dircolors-like style
+          colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w)=([^:]*)/)] : {}
+          @passed_color = "\e[#{colors["pass"] || "32"}m"
+          @failed_color = "\e[#{colors["fail"] || "31"}m"
           @reset_color = "\e[m"
         else
-          @failed_color = @reset_color = ""
+          @passed_color = @failed_color = @reset_color = ""
         end
         if color or @options[:job_status] == :replace
           @options[:job_status] ||= :replace unless @verbose

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]