[Groonga-commit] groonga/groonga at 1998137 [master] test windows fix for command line test (#908)

Back to archive index
Kentaro Hayashi null+****@clear*****
Tue Feb 26 11:28:28 JST 2019


Kentaro Hayashi	2019-02-26 11:28:28 +0900 (Tue, 26 Feb 2019)

  Revision: 199813730bc0e9f6e8fc1ec60a1d25e959ebbcc4
  https://github.com/groonga/groonga/commit/199813730bc0e9f6e8fc1ec60a1d25e959ebbcc4

  Message:
    test windows fix for command line test (#908)
    
    * test windows: search .exe under multibyte character directory name
    
    In the previous versions, find_program can't find groonga.exe or
    grndb.exe under multibyte character directory name.
    
    So, it need to search program with ".exe" suffix on Windows.
    It also requires File::ALT_SEPARATOR because command_line/run-test.rb
    output is unified into File::ALT_SEPARATOR as path separator.
    
    * test windows: don't break multibyte character in PATH
    
    It seems that system({},...) or spawn({}, ...) breaks multibyte
    character in ENV["PATH"].
    
    * test windows: use RbConfig::CONFIG["EXEEXT"]
    
    Linux: RbConfig::CONFIG["EXEEXT"] #=> ""
    Windows: RbConfig::CONFIG["EXEEXT"] #=> ".exe"
    
    So, name + RbConfig::CONFIG["EXEEXT"] is enough, but still need
    to use File::ALT_SEPARATOR because grndb test output contains full
    path to binary (It contains \\grndb.exe not /grndb.exe, so we can't
    use File.join() in this context because File.join use File::SEPARATOR
    instead of File::ALT_SEPARATOR.)
    
    * test: simplify
    
    * test: use same separator for consistency

  Modified files:
    test/command_line/helper/command_runner.rb

  Modified: test/command_line/helper/command_runner.rb (+7 -7)
===================================================================
--- test/command_line/helper/command_runner.rb    2019-02-15 11:51:02 +0900 (7e4440c29)
+++ test/command_line/helper/command_runner.rb    2019-02-26 11:28:28 +0900 (7f9444dc7)
@@ -103,10 +103,12 @@ module CommandRunner
   end
 
   def find_program(name, options={})
+    name += RbConfig::CONFIG["EXEEXT"]
     ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
-      program_path = File.join(path, name)
-      libs_lt_program_path = File.join(path, ".libs", "lt-#{name}")
-      libs_program_path = File.join(path, ".libs", name)
+      separator = File::ALT_SEPARATOR || File::SEPARATOR
+      program_path = [path, name].join(separator)
+      libs_lt_program_path = [path, ".libs", "lt-#{name}"].join(separator)
+      libs_program_path = [path, ".libs", name].join(separator)
       if options[:prefer_libtool]
         candidates = [
           libs_lt_program_path,
@@ -143,7 +145,6 @@ module CommandRunner
 
   private
   def run_command_interactive(*command_line)
-    env = {}
     IO.pipe do |input_read, input_write|
       IO.pipe do |output_read, output_write|
         options = {
@@ -151,7 +152,7 @@ module CommandRunner
           :out => output_write,
           :err => @error_output_log_path.to_s,
         }
-        pid = spawn(env, *command_line, options)
+        pid = spawn(*command_line, options)
         input_read.close
         output_write.close
         external_process = ExternalProcess.new(pid, input_write, output_read)
@@ -171,12 +172,11 @@ module CommandRunner
   end
 
   def run_command_sync(*command_line)
-    env = {}
     options = {
       :out => @output_log_path.to_s,
       :err => @error_output_log_path.to_s,
     }
-    succeeded = system(env, *command_line, options)
+    succeeded = system(*command_line, options)
     output = @output_log_path.read
     error_output = @error_output_log_path.read
     unless succeeded
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190226/01b7e3b1/attachment-0001.html>


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