[Groonga-commit] groonga/grntest at e17d824 [master] Add eval directive

Back to archive index
Kouhei Sutou null+****@clear*****
Sun May 12 06:41:51 JST 2019


Kouhei Sutou	2019-05-12 06:41:51 +0900 (Sun, 12 May 2019)

  Revision: e17d82432ff5636b87f0b81deebf70e06bf6c5dc
  https://github.com/groonga/grntest/commit/e17d82432ff5636b87f0b81deebf70e06bf6c5dc

  Message:
    Add eval directive

  Modified files:
    lib/grntest/execution-context.rb
    lib/grntest/executors/base-executor.rb
    lib/grntest/test-runner.rb
    lib/grntest/tester.rb
    lib/grntest/variable-expander.rb

  Modified: lib/grntest/execution-context.rb (+24 -1)
===================================================================
--- lib/grntest/execution-context.rb    2019-05-09 19:06:34 +0900 (968ef99)
+++ lib/grntest/execution-context.rb    2019-05-12 06:41:51 +0900 (a365661)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2018  Kouhei Sutou <kou****@clear*****>
+# Copyright (C) 2012-2019  Kouhei Sutou <kou****@clear*****>
 #
 # 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
@@ -17,6 +17,8 @@ module Grntest
   class ExecutionContext
     attr_writer :logging
     attr_accessor :base_directory, :temporary_directory_path, :db_path
+    attr_accessor :plugins_directory
+    attr_accessor :plugin_extension
     attr_accessor :groonga_suggest_create_dataset
     attr_accessor :result
     attr_accessor :output_type
@@ -35,6 +37,8 @@ module Grntest
       @base_directory = Pathname(".")
       @temporary_directory_path = Pathname("tmp")
       @db_path = Pathname("db")
+      @plugins_directory = nil
+      @plugin_extension = guess_plugin_extension
       @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
       @n_nested = 0
       @result = []
@@ -101,6 +105,15 @@ module Grntest
       @db_path.relative_path_from(@temporary_directory_path)
     end
 
+    def libtool_directory
+      @plugins_directory.find do |sub_path|
+        if sub_path.directory? and sub_path.basename.to_s == ".libs"
+          return ".libs/"
+        end
+      end
+      ""
+    end
+
     def omitted?
       @omitted
     end
@@ -132,5 +145,15 @@ module Grntest
         @query_log = nil
       end
     end
+
+    private
+    def guess_plugin_extension
+      case RUBY_PLATFORM
+      when /mingw|mswin/
+        "dll"
+      else
+        "so"
+      end
+    end
   end
 end

  Modified: lib/grntest/executors/base-executor.rb (+7 -0)
===================================================================
--- lib/grntest/executors/base-executor.rb    2019-05-09 19:06:34 +0900 (cc1a82d)
+++ lib/grntest/executors/base-executor.rb    2019-05-12 06:41:51 +0900 (c82d50b)
@@ -315,6 +315,11 @@ module Grntest
         end
       end
 
+      def execute_directive_eval(parser, line, content, options)
+        groonga_command = content.split(" ", 2)[1]
+        parser << "#{expand_variables(groonga_command)}\n"
+      end
+
       def execute_directive(parser, line, content)
         command, *options = Shellwords.split(content)
         case command
@@ -348,6 +353,8 @@ module Grntest
           execute_directive_collect_query_log(line, content, options)
         when "generate-series"
           execute_directive_generate_series(parser, line, content, options)
+        when "eval"
+          execute_directive_eval(parser, line, content, options)
         else
           log_input(line)
           log_error("#|e| unknown directive: <#{command}>")

  Modified: lib/grntest/test-runner.rb (+1 -0)
===================================================================
--- lib/grntest/test-runner.rb    2019-05-09 19:06:34 +0900 (e557326)
+++ lib/grntest/test-runner.rb    2019-05-12 06:41:51 +0900 (8671a6c)
@@ -134,6 +134,7 @@ module Grntest
         context.temporary_directory_path = directory_path
         context.db_path = db_path
         context.base_directory =****@teste*****_directory.expand_path
+        context.plugins_directory =****@teste*****_directory.expand_path
         context.groonga_suggest_create_dataset =
           @tester.groonga_suggest_create_dataset
         context.output_type =****@teste*****_type

  Modified: lib/grntest/tester.rb (+16 -4)
===================================================================
--- lib/grntest/tester.rb    2019-05-09 19:06:34 +0900 (be6b654)
+++ lib/grntest/tester.rb    2019-05-12 06:41:51 +0900 (5b0528c)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2018  Kouhei Sutou <kou****@clear*****>
+# Copyright (C) 2012-2019  Kouhei Sutou <kou****@clear*****>
 #
 # 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
@@ -415,6 +415,14 @@ module Grntest
       end
     end
 
+    def plugins_directory
+      groonga_path = Pathname(@groonga)
+      unless groonga_path.absolute?
+        groonga_path = Pathname(resolve_command_path(@groonga)).expand_path
+      end
+      groonga_path.parent.parent + "plugins"
+    end
+
     private
     def load_tests(*targets)
       default_group_name = "."
@@ -471,7 +479,7 @@ module Grntest
       @vagrind_gen_suppressions = false
     end
 
-    def command_exist?(name)
+    def resolve_command_path(name)
       exeext = RbConfig::CONFIG["EXEEXT"]
       ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
         raw_candidate = File.join(path, name)
@@ -480,10 +488,14 @@ module Grntest
           "#{raw_candidate}#{exeext}",
         ]
         candidates.each do |candidate|
-          return true if File.executable?(candidate)
+          return candidate if File.executable?(candidate)
         end
       end
-      false
+      nil
+    end
+
+    def command_exist?(name)
+      not resolve_command_path(name).nil?
     end
 
     def guess_color_availability

  Modified: lib/grntest/variable-expander.rb (+7 -1)
===================================================================
--- lib/grntest/variable-expander.rb    2019-05-09 19:06:34 +0900 (efcd3eb)
+++ lib/grntest/variable-expander.rb    2019-05-12 06:41:51 +0900 (6adfab8)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016  Kouhei Sutou <kou****@clear*****>
+# Copyright (C) 2016-2019  Kouhei Sutou <kou****@clear*****>
 #
 # 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
@@ -28,6 +28,12 @@ module Grntest
           @context.db_path.parent.to_s
         when "base_directory"
           @context.base_directory.to_s
+        when "plugins_directory"
+          @context.plugins_directory.to_s
+        when "libtool_directory"
+          @context.libtool_directory
+        when "plugin_extension"
+          @context.plugin_extension
         else
           matched
         end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190512/e74bd1bb/attachment-0001.html>


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