[Groonga-commit] groonga/grntest at ccda90d [master] Support defining environment variables by "#$NAME=VALUE"

Back to archive index

Kouhei Sutou null+****@clear*****
Fri May 6 17:28:08 JST 2016


Kouhei Sutou	2016-05-06 17:28:08 +0900 (Fri, 06 May 2016)

  New Revision: ccda90d9f601cba1e233e55753deadf256674d61
  https://github.com/groonga/grntest/commit/ccda90d9f601cba1e233e55753deadf256674d61

  Message:
    Support defining environment variables by "#$NAME=VALUE"

  Modified files:
    lib/grntest/test-runner.rb

  Modified: lib/grntest/test-runner.rb (+19 -3)
===================================================================
--- lib/grntest/test-runner.rb    2016-05-06 14:37:55 +0900 (50cc099)
+++ lib/grntest/test-runner.rb    2016-05-06 17:28:08 +0900 (f7d5eb9)
@@ -196,7 +196,7 @@ module Grntest
           groonga_input = input_write
           groonga_output = output_read
 
-          env = {}
+          env = extract_custom_env
           spawn_options = {}
           command_line = groonga_command_line(context, spawn_options)
           if Platform.windows?
@@ -333,7 +333,7 @@ call chdir("#{context.temporary_directory_path}")
       port = 50041 +****@worke*****
       pid_file_path = context.temporary_directory_path + "groonga.pid"
 
-      env = {}
+      env = extract_custom_env
       spawn_options = {}
       command_line = groonga_http_command(host, port, pid_file_path, context,
                                           spawn_options)
@@ -451,7 +451,8 @@ events {
 }
         GLOBAL
 
-        ENV.each do |key, value|
+        env = ENV.merge(extract_custom_env)
+        env.each do |key, value|
           next unless key.start_with?("GRN_")
           config_file.puts(<<-ENV)
 env #{key};
@@ -627,6 +628,21 @@ http {
       @worker.test_script_path
     end
 
+    def extract_custom_env
+      return {} unless test_script_path.exist?
+
+      env = {}
+      test_script_path.open("r:ascii-8bit") do |script_file|
+        script_file.each_line do |line|
+          case line
+          when /\A\#\$([a-zA-Z_\d]+)=(.*)/
+            env[$1] = $2.strip
+          end
+        end
+      end
+      env
+    end
+
     def have_extension?
       not test_script_path.extname.empty?
     end
-------------- next part --------------
HTML����������������������������...
Download 



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