[Groonga-commit] groonga/groonga-query-log at 7ceb7e3 [master] run-regression-test verify-server: support tar.gz query logs

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jul 5 15:18:40 JST 2018


Kouhei Sutou	2018-07-05 15:18:40 +0900 (Thu, 05 Jul 2018)

  New Revision: 7ceb7e32b1f9f29c2c463d8f97b355b4aa4d2dcd
  https://github.com/groonga/groonga-query-log/commit/7ceb7e32b1f9f29c2c463d8f97b355b4aa4d2dcd

  Message:
    run-regression-test verify-server: support tar.gz query logs

  Modified files:
    lib/groonga-query-log/command/run-regression-test.rb
    lib/groonga-query-log/command/verify-server.rb

  Modified: lib/groonga-query-log/command/run-regression-test.rb (+2 -2)
===================================================================
--- lib/groonga-query-log/command/run-regression-test.rb    2018-07-03 15:05:58 +0900 (52b1069)
+++ lib/groonga-query-log/command/run-regression-test.rb    2018-07-05 15:18:40 +0900 (43450ed)
@@ -474,11 +474,11 @@ module GroongaQueryLog
         end
 
         def query_log_paths
-          Pathname.glob("#{@input_directory}/query-logs/**/*.log").sort
+          Pathname.glob("#{@input_directory}/query-logs/**/*.{log,tar.gz}").sort
         end
 
         def test_log_path(query_log_path)
-          @working_directory + "results" + query_log_path.basename
+          @working_directory + "results" + "#{query_log_path.basename}.log"
         end
 
         def use_persistent_cache?

  Modified: lib/groonga-query-log/command/verify-server.rb (+28 -2)
===================================================================
--- lib/groonga-query-log/command/verify-server.rb    2018-07-03 15:05:58 +0900 (e562e26)
+++ lib/groonga-query-log/command/verify-server.rb    2018-07-05 15:18:40 +0900 (a8fd3bb)
@@ -15,6 +15,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 require "optparse"
+require "rubygems/package"
 
 require "groonga-query-log"
 
@@ -33,9 +34,18 @@ module GroongaQueryLog
           same = verifier.verify($stdin, &callback)
         else
           input_paths.each do |input_path|
-            File.open(input_path) do |input|
-              unless verifier.verify(input, &callback)
+            case input_path
+            when /\.tar\.gz\z/
+              unless verify_tar_gz(verifier, input_path)
                 same = false
+                return false if****@optio*****_on_failure?
+              end
+            else
+              File.open(input_path) do |input|
+                unless verifier.verify(input, &callback)
+                  same = false
+                  return false if****@optio*****_on_failure?
+                end
               end
             end
           end
@@ -44,6 +54,22 @@ module GroongaQueryLog
       end
 
       private
+      def verify_tar_gz(verifier, tar_gz_path, &callback)
+        same = true
+        Zlib::GzipReader.open(tar_gz_path) do |gzip|
+          Gem::Package::TarReader.new(gzip) do |tar|
+            tar.each do |entry|
+              next unless entry.file?
+              unless verifier.verify(StringIO.new(entry.read), &callback)
+                same = false
+                return false if****@optio*****_on_failure?
+              end
+            end
+          end
+        end
+        same
+      end
+
       def create_parser
         parser = OptionParser.new
         parser.version = VERSION
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180705/19d6e095/attachment-0001.htm 



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