[Groonga-commit] groonga/fluent-plugin-droonga at 0060f66 [master] test: move helper codes into helper/ directory

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jul 17 15:10:51 JST 2013


Kouhei Sutou	2013-07-17 15:10:51 +0900 (Wed, 17 Jul 2013)

  New Revision: 0060f66330c598b9ef28636da2ac461b7faa35a7
  https://github.com/groonga/fluent-plugin-droonga/commit/0060f66330c598b9ef28636da2ac461b7faa35a7

  Message:
    test: move helper codes into helper/ directory

  Added files:
    test/helper/fixture.rb
  Copied files:
    test/helper/sandbox.rb
      (from test/helper.rb)
  Modified files:
    test/helper.rb

  Modified: test/helper.rb (+2 -72)
===================================================================
--- test/helper.rb    2013-07-16 17:52:48 +0900 (a26eed0)
+++ test/helper.rb    2013-07-17 15:10:51 +0900 (d30cc8a)
@@ -13,78 +13,8 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-module Sandbox
-  class << self
-    def included(base)
-      base.setup :setup_sandbox, :before => :prepend
-      base.teardown :teardown_sandbox, :after => :append
-    end
-  end
-
-  def setup_sandbox
-    setup_temporary_directory
-
-    setup_context
-
-    @database_path = @temporary_directory + "database"
-    @database = nil
-  end
-
-  def setup_temporary_directory
-    @base_temporary_directory = Pathname(File.dirname(__FILE__)) + "tmp"
-    memory_file_system = "/run/shm"
-    if File.exist?(memory_file_system)
-      FileUtils.mkdir_p(@base_temporary_directory.parent.to_s)
-      FileUtils.rm_f(@base_temporary_directory.to_s)
-      FileUtils.ln_s(memory_file_system, @base_temporary_directory.to_s)
-    else
-      FileUtils.mkdir_p(@base_temporary_directory.to_s)
-    end
-
-    @temporary_directory = @base_temporary_directory + "fluent-plugin-droonga"
-    FileUtils.rm_rf(@temporary_directory.to_s)
-    FileUtils.mkdir_p(@temporary_directory.to_s)
-  end
-
-  def setup_context
-    Groonga::Context.default = nil
-    Groonga::Context.default_options = nil
-  end
-
-  def restore(dumped_command)
-    context = Groonga::Context.new
-    database = context.create_database(@database_path.to_s)
-    context.restore(dumped_command)
-    database.close
-    context.close
-  end
-
-  def teardown_sandbox
-    Groonga::Context.default.close
-    Groonga::Context.default = nil
-    GC.start
-    teardown_temporary_directory
-  end
-
-  def teardown_temporary_directory
-    FileUtils.rm_rf(@temporary_directory.to_s)
-    FileUtils.rm_rf(@base_temporary_directory.to_s)
-  end
-end
-
-module Fixture
-  def fixture_directory
-    File.join(File.dirname(__FILE__), "fixtures")
-  end
-
-  def fixture_path(*path_components)
-    File.join(fixture_directory, *path_components)
-  end
-
-  def fixture_data(*path_components)
-    File.read(fixture_path(*path_components))
-  end
-end
+require_relative "helper/sandbox"
+require_relative "helper/fixture"
 
 class Test::Unit::TestCase
   include Sandbox

  Added: test/helper/fixture.rb (+28 -0) 100644
===================================================================
--- /dev/null
+++ test/helper/fixture.rb    2013-07-17 15:10:51 +0900 (efb786c)
@@ -0,0 +1,28 @@
+# Copyright (C) 2013 droonga project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+module Fixture
+  def fixture_directory
+    File.join(File.dirname(__FILE__), "..", "fixtures")
+  end
+
+  def fixture_path(*path_components)
+    File.join(fixture_directory, *path_components)
+  end
+
+  def fixture_data(*path_components)
+    File.read(fixture_path(*path_components))
+  end
+end

  Copied: test/helper/sandbox.rb (+0 -19) 86%
===================================================================
--- test/helper.rb    2013-07-16 17:52:48 +0900 (a26eed0)
+++ test/helper/sandbox.rb    2013-07-17 15:10:51 +0900 (e6dd5c0)
@@ -71,22 +71,3 @@ module Sandbox
     FileUtils.rm_rf(@base_temporary_directory.to_s)
   end
 end
-
-module Fixture
-  def fixture_directory
-    File.join(File.dirname(__FILE__), "fixtures")
-  end
-
-  def fixture_path(*path_components)
-    File.join(fixture_directory, *path_components)
-  end
-
-  def fixture_data(*path_components)
-    File.read(fixture_path(*path_components))
-  end
-end
-
-class Test::Unit::TestCase
-  include Sandbox
-  include Fixture
-end
-------------- next part --------------
HTML����������������������������...
Download 



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