[Groonga-commit] groonga/grntest [master] Truncate long test name

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Sat Aug 11 16:10:34 JST 2012


Kouhei Sutou	2012-08-11 16:10:34 +0900 (Sat, 11 Aug 2012)

  New Revision: 047b99a7ad311a79a5991ed1d1bcea15c4cecff2
  https://github.com/groonga/grntest/commit/047b99a7ad311a79a5991ed1d1bcea15c4cecff2

  Log:
    Truncate long test name

  Modified files:
    lib/groonga/tester.rb

  Modified: lib/groonga/tester.rb (+21 -3)
===================================================================
--- lib/groonga/tester.rb    2012-08-11 15:57:19 +0900 (fee342c)
+++ lib/groonga/tester.rb    2012-08-11 16:10:34 +0900 (f225c20)
@@ -1316,11 +1316,24 @@ EOF
       end
 
       def report_test_result(result, label)
-        message = " %10.4fs [%s]" % [result.elapsed_time, label]
+        message = test_result_message(result, label)
         message = message.rjust(@term_width - @current_column) if @term_width > 0
         puts(message)
       end
 
+      def test_result_message(result, label)
+        " %7.4fs [%s]" % [result.elapsed_time, label]
+      end
+
+      def max_test_result_width
+        @max_test_result_width ||= guess_max_test_result_width
+      end
+
+      def guess_max_test_result_width
+        result = Result.new
+        test_result_message(result, "not checked").bytesize
+      end
+
       def justify(message, width)
         return " " * width if message.nil?
         return message.ljust(width) if message.bytesize <= width
@@ -1382,6 +1395,10 @@ EOF
 
       def start_test(worker)
         label = "  #{worker.test_name}"
+        if @term_width > 0
+          width = @term_width - @current_column - max_test_result_width
+          label = justify(label, width)
+        end
         print(label)
         @output.flush
       end
@@ -1494,10 +1511,11 @@ EOF
       def draw_test_line(worker)
         clear_line
         if worker.test_name
-          puts("  #{worker.test_name}")
+          label = "  #{worker.test_name}"
         else
-          puts("  #{worker.statistics}")
+          label = "  #{worker.statistics}"
         end
+        puts(justify(label, @term_width))
       end
 
       def redraw
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index