[Groonga-commit] groonga/grntest [master] Add --keep-database for debug

Back to archive index

null+****@clear***** null+****@clear*****
2012年 4月 9日 (月) 11:52:32 JST


Kouhei Sutou	2012-04-09 11:52:32 +0900 (Mon, 09 Apr 2012)

  New Revision: dcde6d2d50e53667acd7336131039e744417483d

  Log:
    Add --keep-database for debug

  Modified files:
    lib/groonga/tester.rb

  Modified: lib/groonga/tester.rb (+21 -1)
===================================================================
--- lib/groonga/tester.rb    2012-03-16 19:25:04 +0900 (2dd28aa)
+++ lib/groonga/tester.rb    2012-04-09 11:52:32 +0900 (86009de)
@@ -77,6 +77,12 @@ module Groonga
           diff_option_is_specified = true
         end
 
+        parser.on("--[no-]keep-database",
+                  "Keep used database for debug after test is finished",
+                  "(#{tester.keep_database?})") do |boolean|
+          tester.keep_database = boolean
+        end
+
         parser.on("--version",
                   "Show version and exit") do
           puts(GroongaTester::VERSION)
@@ -89,6 +95,7 @@ module Groonga
 
     attr_accessor :groonga, :groonga_suggest_create_dataset
     attr_accessor :base_directory, :diff, :diff_options
+    attr_writer :keep_database
     def initialize
       @groonga = "groonga"
       @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
@@ -119,6 +126,10 @@ module Groonga
       succeeded
     end
 
+    def keep_database?
+      @keep_database
+    end
+
     private
     def collect_test_files(test_directory)
       test_files = Pathname.glob(test_directory + "**" + "*.test")
@@ -236,10 +247,19 @@ module Groonga
         begin
           yield path
         ensure
-          FileUtils.rm_rf(path)
+          if****@teste*****_database? and File.exist?(path)
+            FileUtils.rm_rf(keep_database_path)
+            FileUtils.mv(path, keep_database_path)
+          else
+            FileUtils.rm_rf(path)
+          end
         end
       end
 
+      def keep_database_path
+        @test_script_path.to_s.gsub(/\//, ".")
+      end
+
       def run_groonga(db_path)
         IO.popen([@tester.groonga, "-n", db_path], "r+") do |io|
           begin




Groonga-commit メーリングリストの案内
Back to archive index