[Groonga-commit] groonga/groonga-query-log at 4a5150d [master] run-regression-test: support loading data by Ruby

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Sep 7 09:13:59 JST 2018


Kouhei Sutou	2018-09-07 09:13:59 +0900 (Fri, 07 Sep 2018)

  Revision: 4a5150d6c4b058dcdd0383eb97c635420226ab0a
  https://github.com/groonga/groonga-query-log/commit/4a5150d6c4b058dcdd0383eb97c635420226ab0a

  Message:
    run-regression-test: support loading data by Ruby

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

  Modified: lib/groonga-query-log/command/run-regression-test.rb (+24 -12)
===================================================================
--- lib/groonga-query-log/command/run-regression-test.rb    2018-09-04 11:06:02 +0900 (43450ed)
+++ lib/groonga-query-log/command/run-regression-test.rb    2018-09-07 09:13:59 +0900 (97578af)
@@ -277,16 +277,28 @@ module GroongaQueryLog
           return if @database_path.exist?
           FileUtils.mkdir_p(@database_path.dirname.to_s)
           system(@groonga, "-n", @database_path.to_s, "quit")
-          grn_files.each do |grn_file|
-            command = [
-              @groonga,
-              "--log-path", log_path.to_s,
-              "--file", grn_file.to_s,
-              @database_path.to_s,
-            ]
+          load_files.each do |load_file|
+            if load_file.extname == ".rb"
+              env = {
+                "GROONGA_LOG_PATH" => log_path.to_s,
+              }
+              command = [
+                RbConfig.ruby,
+                load_file.to_s,
+                @database_path.to_s,
+              ]
+            else
+              env = {}
+              command = [
+                @groonga,
+                "--log-path", log_path.to_s,
+                "--file", grn_file.to_s,
+                @database_path.to_s,
+              ]
+            end
             command_line = command.join(" ")
             puts("Running...: #{command_line}")
-            pid = spawn(*command)
+            pid = spawn(env, *command)
             begin
               pid, status = Process.waitpid2(pid)
             rescue Interrupt
@@ -336,7 +348,7 @@ module GroongaQueryLog
           end
         end
 
-        def grn_files
+        def load_files
           files = schema_files
           files += data_files if @options[:load_data]
           files += index_files
@@ -344,15 +356,15 @@ module GroongaQueryLog
         end
 
         def schema_files
-          Pathname.glob("#{@input_directory}/schema/**/*.grn").sort
+          Pathname.glob("#{@input_directory}/schema/**/*.{grn,rb}").sort
         end
 
         def index_files
-          Pathname.glob("#{@input_directory}/indexes/**/*.grn").sort
+          Pathname.glob("#{@input_directory}/indexes/**/*.{grn,rb}").sort
         end
 
         def data_files
-          Pathname.glob("#{@input_directory}/data/**/*.grn").sort
+          Pathname.glob("#{@input_directory}/data/**/*.{grn,rb}").sort
         end
       end
 
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180907/44e64f27/attachment-0001.htm 



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