[Groonga-commit] groonga/grntest [master] inplace reporter: colorize progress

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Aug 11 19:09:06 JST 2012


Kouhei Sutou	2012-08-11 19:09:06 +0900 (Sat, 11 Aug 2012)

  New Revision: 423345ab8d122e9e00c27cb2d0f7ebf461ffeb1d
  https://github.com/groonga/grntest/commit/423345ab8d122e9e00c27cb2d0f7ebf461ffeb1d

  Log:
    inplace reporter: colorize progress

  Modified files:
    lib/groonga/tester.rb

  Modified: lib/groonga/tester.rb (+15 -13)
===================================================================
--- lib/groonga/tester.rb    2012-08-11 19:00:17 +0900 (403e8bb)
+++ lib/groonga/tester.rb    2012-08-11 19:09:06 +0900 (99834cc)
@@ -318,16 +318,6 @@ module Groonga
       def test_not_checked
         @n_not_checked_tests += 1
       end
-
-      def status
-        if n_failed_tests > 0
-          :failure
-        elsif n_not_checked_tests > 0
-          :no_check
-        else
-          :success
-        end
-      end
     end
 
     class Worker
@@ -1446,6 +1436,16 @@ EOF
         string.gsub(/\e\[[0-9;]+m/, "").size
       end
 
+      def result_status(result)
+        if result.n_failed_tests > 0
+          :failure
+        elsif result.n_not_checked_tests > 0
+          :no_check
+        else
+          :success
+        end
+      end
+
       def colorize(message, situation)
         return message unles****@teste*****_color?
         case situation
@@ -1686,7 +1686,7 @@ EOF
 
       def draw_status_line(worker)
         clear_line
-        situation = worker.result.status
+        situation = result_status(worker.result)
         left = "[#{colorize(worker.id, situation)}] "
         right = " [#{worker.status}]"
         rest_width = @term_width - @current_column
@@ -1719,15 +1719,17 @@ EOF
         progress_width -= finish_mark.bytesize
         progress_width -= statistics.bytesize
         finished_mark = "-"
+        situation = result_status(@test_suites_result)
         if n_done_tests == n_total_tests
-          progress = finished_mark * progress_width
+          progress = colorize(finished_mark * progress_width, situation)
         else
           current_mark = ">"
           finished_marks_width = (progress_width * finished_test_ratio).ceil
           finished_marks_width -= current_mark.bytesize
           finished_marks_width = [0, finished_marks_width].max
           progress = finished_mark * finished_marks_width + current_mark
-          progress = progress.ljust(progress_width)
+          progress = colorize(progress, situation)
+          progress << " " * (progress_width - string_width(progress))
         end
         puts("#{start_mark}#{progress}#{finish_mark}#{statistics}")
       end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index