[Groonga-commit] groonga/grntest at c5bc6d6 [master] Extract execution context

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Aug 12 11:48:15 JST 2013


Kouhei Sutou	2013-08-12 11:48:15 +0900 (Mon, 12 Aug 2013)

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

  Message:
    Extract execution context

  Added files:
    lib/grntest/execution-context.rb
  Modified files:
    lib/grntest/tester.rb

  Added: lib/grntest/execution-context.rb (+89 -0) 100644
===================================================================
--- /dev/null
+++ lib/grntest/execution-context.rb    2013-08-12 11:48:15 +0900 (b87640c)
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012-2013  Kouhei Sutou <kou �� clear-code.com>
+#
+# 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+module Grntest
+  class ExecutionContext
+    attr_writer :logging
+    attr_accessor :base_directory, :temporary_directory_path, :db_path
+    attr_accessor :groonga_suggest_create_dataset
+    attr_accessor :result
+    attr_accessor :output_type
+    attr_accessor :on_error
+    attr_accessor :abort_tag
+    def initialize
+      @logging = true
+      @base_directory = Pathname(".")
+      @temporary_directory_path = Pathname("tmp")
+      @db_path = Pathname("db")
+      @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
+      @n_nested = 0
+      @result = []
+      @output_type = "json"
+      @log = nil
+      @on_error = :default
+      @abort_tag = nil
+      @omitted = false
+    end
+
+    def logging?
+      @logging
+    end
+
+    def execute
+      @n_nested += 1
+      yield
+    ensure
+      @n_nested -= 1
+    end
+
+    def top_level?
+      @n_nested == 1
+    end
+
+    def log_path
+      @temporary_directory_path + "groonga.log"
+    end
+
+    def log
+      @log ||= File.open(log_path.to_s, "a+")
+    end
+
+    def relative_db_path
+      @db_path.relative_path_from(@temporary_directory_path)
+    end
+
+    def omitted?
+      @omitted
+    end
+
+    def error
+      case @on_error
+      when :omit
+        omit
+      end
+    end
+
+    def omit
+      @omitted = true
+      abort
+    end
+
+    def abort
+      throw @abort_tag
+    end
+  end
+end

  Modified: lib/grntest/tester.rb (+3 -73)
===================================================================
--- lib/grntest/tester.rb    2013-08-12 11:39:17 +0900 (c1b480f)
+++ lib/grntest/tester.rb    2013-08-12 11:48:15 +0900 (1582244)
@@ -30,6 +30,7 @@ require "groonga/command"
 
 require "grntest/version"
 require "grntest/reporters"
+require "grntest/execution-context"
 
 module Grntest
   class Tester
@@ -809,7 +810,7 @@ module Grntest
             FileUtils.mkdir_p(db_dir.to_s)
             db_path = db_dir + "db"
           end
-          context = Executor::Context.new
+          context = Execution::Context.new
           context.temporary_directory_path = directory_path
           context.db_path = db_path
           context.base_directory =****@teste*****_directory.expand_path
@@ -1192,77 +1193,6 @@ EOF
     end
 
     class Executor
-      class Context
-        attr_writer :logging
-        attr_accessor :base_directory, :temporary_directory_path, :db_path
-        attr_accessor :groonga_suggest_create_dataset
-        attr_accessor :result
-        attr_accessor :output_type
-        attr_accessor :on_error
-        attr_accessor :abort_tag
-        def initialize
-          @logging = true
-          @base_directory = Pathname(".")
-          @temporary_directory_path = Pathname("tmp")
-          @db_path = Pathname("db")
-          @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
-          @n_nested = 0
-          @result = []
-          @output_type = "json"
-          @log = nil
-          @on_error = :default
-          @abort_tag = nil
-          @omitted = false
-        end
-
-        def logging?
-          @logging
-        end
-
-        def execute
-          @n_nested += 1
-          yield
-        ensure
-          @n_nested -= 1
-        end
-
-        def top_level?
-          @n_nested == 1
-        end
-
-        def log_path
-          @temporary_directory_path + "groonga.log"
-        end
-
-        def log
-          @log ||= File.open(log_path.to_s, "a+")
-        end
-
-        def relative_db_path
-          @db_path.relative_path_from(@temporary_directory_path)
-        end
-
-        def omitted?
-          @omitted
-        end
-
-        def error
-          case @on_error
-          when :omit
-            omit
-          end
-        end
-
-        def omit
-          @omitted = true
-          abort
-        end
-
-        def abort
-          throw @abort_tag
-        end
-      end
-
       module ReturnCode
         SUCCESS = 0
       end
@@ -1275,7 +1205,7 @@ EOF
         @current_command_name = nil
         @output_type = nil
         @long_timeout = default_long_timeout
-        @context = context || Context.new
+        @context = context || ExecutionContext.new
       end
 
       def execute(script_path)
-------------- next part --------------
HTML����������������������������...
다운로드 



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