[Groonga-commit] droonga/drntest at 3706fa3 [master] Sort dump responses for stable test result

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jul 15 22:32:52 JST 2014


Kouhei Sutou	2014-07-15 22:32:52 +0900 (Tue, 15 Jul 2014)

  New Revision: 3706fa3de13a0a1c1d8d60b34b5ca3ba217b84a7
  https://github.com/droonga/drntest/commit/3706fa3de13a0a1c1d8d60b34b5ca3ba217b84a7

  Message:
    Sort dump responses for stable test result
    
    It breaks table/column dependency resolution by dump command. But stable
    test result will be important rather than it.
    
    If we have more intelligent algorithm for stable test result, we should
    replace this implementation with the intelligent algorithm.

  Added files:
    lib/drntest/responses-normalizer.rb
  Modified files:
    lib/drntest/test-executor.rb

  Added: lib/drntest/responses-normalizer.rb (+61 -0) 100644
===================================================================
--- /dev/null
+++ lib/drntest/responses-normalizer.rb    2014-07-15 22:32:52 +0900 (99a7715)
@@ -0,0 +1,61 @@
+# Copyright (C) 2014  Droonga Project
+#
+# 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+module Drntest
+  class ResponsesNormalizer
+    def initialize(request, responses)
+      @request = request
+      @responses = responses
+    end
+
+    def normalize
+      return @responses unless dump_command?
+
+      normalize_dump_responses
+    end
+
+    private
+    def dump_command?
+      @request["type"] == "dump"
+    end
+
+    DUMP_TYPE_ORDER = [
+      "dump.start",
+      "dump.result",
+      "dump.table",
+      "dump.column",
+      "dump.record",
+      "dump.end",
+    ]
+    def normalize_dump_responses
+      @responses.sort_by do |response|
+        type = response["type"]
+        type_order = DUMP_TYPE_ORDER.index(type)
+        body = response["body"]
+        case type
+        when "dump.table"
+          body_order = body["name"]
+        when "dump.column"
+          body_order = "#{body['table']}.#{body['name']}"
+        when "dump.record"
+          body_order = "#{body['table']}.#{body['key']}"
+        else
+          body_order = ""
+        end
+        [type_order, body_order]
+      end
+    end
+  end
+end

  Modified: lib/drntest/test-executor.rb (+9 -1)
===================================================================
--- lib/drntest/test-executor.rb    2014-07-15 22:18:36 +0900 (274de15)
+++ lib/drntest/test-executor.rb    2014-07-15 22:32:52 +0900 (6782c2e)
@@ -17,6 +17,7 @@ require "droonga/client"
 
 require "drntest/test-loader"
 require "drntest/response-normalizer"
+require "drntest/responses-normalizer"
 
 module Drntest
   class TestExecutor
@@ -102,10 +103,12 @@ module Drntest
 
       def execute_request(request)
         if @logging
+          responses = []
           request_process =****@clien*****(request) do |raw_response|
-            @responses << clean_response(request, raw_response)
+            responses << clean_response(request, raw_response)
           end
           request_process.wait
+          @responses.concat(normalize_responses(request, responses))
         else
           @requests << @client.request(request) do
           end
@@ -139,6 +142,11 @@ module Drntest
         normalizer.normalize
       end
 
+      def normalize_responses(request, responses)
+        normalizer = ResponsesNormalizer.new(request, responses)
+        normalizer.normalize
+      end
+
       def abort_execution
         throw(@abort_tag)
       end
-------------- next part --------------
HTML����������������������������...
Download 



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