[Groonga-commit] groonga/grntest at 473f9ff [master] buffered-mark reporter: add a new reporter

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Aug 30 12:28:40 JST 2015


Kouhei Sutou	2015-08-30 12:28:40 +0900 (Sun, 30 Aug 2015)

  New Revision: 473f9ff5858db6c450de63f12b2f33354329a69e
  https://github.com/groonga/grntest/commit/473f9ff5858db6c450de63f12b2f33354329a69e

  Message:
    buffered-mark reporter: add a new reporter
    
    It's for Travis CI.

  Copied files:
    lib/grntest/reporters/buffered-mark-reporter.rb
      (from lib/grntest/reporters.rb)
  Modified files:
    lib/grntest/reporters.rb
    lib/grntest/reporters/base-reporter.rb
    lib/grntest/reporters/mark-reporter.rb
    lib/grntest/tester.rb

  Modified: lib/grntest/reporters.rb (+4 -1)
===================================================================
--- lib/grntest/reporters.rb    2015-08-29 23:43:00 +0900 (f5df303)
+++ lib/grntest/reporters.rb    2015-08-30 12:28:40 +0900 (bd1bca9)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2012-2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2015  Kouhei Sutou <kou �� clear-code.com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 require "grntest/reporters/mark-reporter"
+require "grntest/reporters/buffered-mark-reporter"
 require "grntest/reporters/stream-reporter"
 require "grntest/reporters/inplace-reporter"
 
@@ -26,6 +27,8 @@ module Grntest
         case tester.reporter
         when :mark
           MarkReporter.new(tester)
+        when :"buffered-mark"
+          BufferedMarkReporter.new(tester)
         when :stream
           StreamReporter.new(tester)
         when :inplace

  Modified: lib/grntest/reporters/base-reporter.rb (+6 -4)
===================================================================
--- lib/grntest/reporters/base-reporter.rb    2015-08-29 23:43:00 +0900 (399d73d)
+++ lib/grntest/reporters/base-reporter.rb    2015-08-30 12:28:40 +0900 (8faa3d3)
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012-2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2015  Kouhei Sutou <kou �� clear-code.com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -155,7 +153,7 @@ module Grntest
       end
 
       def print(message)
-        @current_column += string_width(message.to_s)
+        increment_current_column(message)
         @output.print(message)
       end
 
@@ -164,6 +162,10 @@ module Grntest
         @output.puts(*messages)
       end
 
+      def increment_current_column(message)
+        @current_column += string_width(message.to_s)
+      end
+
       def reset_current_column
         @current_column = 0
       end

  Copied: lib/grntest/reporters/buffered-mark-reporter.rb (+19 -15) 62%
===================================================================
--- lib/grntest/reporters.rb    2015-08-29 23:43:00 +0900 (f5df303)
+++ lib/grntest/reporters/buffered-mark-reporter.rb    2015-08-30 12:28:40 +0900 (4f0323d)
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012-2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2015  Kouhei Sutou <kou �� clear-code.com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,21 +14,27 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 require "grntest/reporters/mark-reporter"
-require "grntest/reporters/stream-reporter"
-require "grntest/reporters/inplace-reporter"
 
 module Grntest
   module Reporters
-    class << self
-      def create_reporter(tester)
-        case tester.reporter
-        when :mark
-          MarkReporter.new(tester)
-        when :stream
-          StreamReporter.new(tester)
-        when :inplace
-          InplaceReporter.new(tester)
-        end
+    class BufferedMarkReporter < MarkReporter
+      def initialize(tester)
+        super
+        @buffer = ""
+      end
+
+      private
+      def print_new_line
+        puts(@buffer)
+        @buffer.clear
+      end
+
+      def print_mark(mark)
+        increment_current_column(mark)
+        @buffer << mark
+      end
+
+      def flush_mark
       end
     end
   end

  Modified: lib/grntest/reporters/mark-reporter.rb (+23 -11)
===================================================================
--- lib/grntest/reporters/mark-reporter.rb    2015-08-29 23:43:00 +0900 (8b735a0)
+++ lib/grntest/reporters/mark-reporter.rb    2015-08-30 12:28:40 +0900 (220ca42)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2012-2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2015  Kouhei Sutou <kou �� clear-code.com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -45,7 +45,7 @@ module Grntest
       def on_test_failure(worker, result)
         synchronize do
           report_test_result_mark("F", result)
-          puts
+          print_new_line
           report_test(worker, result)
           report_failure(result)
         end
@@ -54,7 +54,7 @@ module Grntest
       def on_test_leak(worker, result)
         synchronize do
           report_test_result_mark("L(#{result.n_leaked_objects})", result)
-          puts
+          print_new_line
           report_test(worker, result)
           if result.checked?
             report_actual(result)
@@ -67,7 +67,7 @@ module Grntest
       def on_test_omission(worker, result)
         synchronize do
           report_test_result_mark("O", result)
-          puts
+          print_new_line
           report_test(worker, result)
           report_actual(result)
         end
@@ -76,7 +76,7 @@ module Grntest
       def on_test_no_check(worker, result)
         synchronize do
           report_test_result_mark("N", result)
-          puts
+          print_new_line
           report_test(worker, result)
           report_actual(result)
         end
@@ -92,23 +92,35 @@ module Grntest
       end
 
       def on_finish(result)
-        puts
-        puts
+        print_new_line
+        print_new_line
         report_summary(result)
       end
 
       private
       def report_test_result_mark(mark, result)
         if @term_width < @current_column + mark.bytesize
-          puts
+          print_new_line
         end
-        print(colorize(mark, result))
+        print_mark(colorize(mark, result))
         if @term_width <= @current_column
-          puts
+          print_new_line
         else
-          @output.flush
+          flush_mark
         end
       end
+
+      def print_new_line
+        puts
+      end
+
+      def print_mark(mark)
+        print(mark)
+      end
+
+      def flush_mark
+        @output.flush
+      end
     end
   end
 end

  Modified: lib/grntest/tester.rb (+1 -1)
===================================================================
--- lib/grntest/tester.rb    2015-08-29 23:43:00 +0900 (a7f8c3e)
+++ lib/grntest/tester.rb    2015-08-30 12:28:40 +0900 (eecc8ee)
@@ -116,7 +116,7 @@ module Grntest
           diff_option_is_specified = true
         end
 
-        available_reporters = [:mark, :stream, :inplace]
+        available_reporters = [:mark, :"buffered-mark", :stream, :inplace]
         available_reporter_labels = available_reporters.join(", ")
         parser.on("--reporter=REPORTER", available_reporters,
                   "Report test result by REPORTER",
-------------- next part --------------
HTML����������������������������...
Download 



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