Kouhei Sutou
null+****@clear*****
Mon Jan 29 00:30:25 JST 2018
Kouhei Sutou 2018-01-29 00:30:25 +0900 (Mon, 29 Jan 2018) New Revision: 263c1dc2a6bfa56198d0370ef4ae2dd5df673df4 https://github.com/ranguba/rroonga/commit/263c1dc2a6bfa56198d0370ef4ae2dd5df673df4 Message: test: stop to use Ruby level logger It may crashed by "allocation in GC mark". Modified files: test/groonga-test-utils.rb test/test-context.rb test/test-database.rb test/test-logger.rb test/test-query-logger.rb Modified: test/groonga-test-utils.rb (+5 -8) =================================================================== --- test/groonga-test-utils.rb 2018-01-29 00:24:22 +0900 (2bd9b362) +++ test/groonga-test-utils.rb 2018-01-29 00:30:25 +0900 (0cf9cdb0) @@ -68,12 +68,10 @@ module GroongaTestUtils @dump_log = false @log_path = @tmp_dir + "groonga.log" - logger = Groonga::FileLogger.new(@log_path.to_s) - Groonga::Logger.register(logger) + Groonga::Logger.path = @log_path.to_s @query_log_path = @tmp_dir + "groonga-query.log" - query_logger = Groonga::FileQueryLogger.new(@query_log_path.to_s) - Groonga::QueryLogger.register(query_logger, :all => true) + Groonga::QueryLogger.path = @query_log_path.to_s end def setup_tables_directory @@ -130,11 +128,10 @@ module GroongaTestUtils def teardown_log_path return unless @dump_log - log_path = Groonga::Logger.log_path - if File.exist?(log_path) - header = "--- log: #{log_path} ---" + if @log_path.exist?(log_path) + header = "--- log: #{@log_path} ---" puts(header) - puts(File.read(log_path)) + puts(@log_path.read) puts("-" * header.length) end if @query_log_path.exist? Modified: test/test-context.rb (+1 -2) =================================================================== --- test/test-context.rb 2018-01-29 00:24:22 +0900 (e16ab3d2) +++ test/test-context.rb 2018-01-29 00:30:25 +0900 (e82895fc) @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2015 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2009-2018 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2016 Masafumi Yokoyama <yokoyama �� clear-code.com> # # This library is free software; you can redistribute it and/or @@ -41,7 +41,6 @@ class ContextTest < Test::Unit::TestCase end def test_create_temporary_database - Groonga::Logger.register(nil) before_files = @tmp_dir.children context = Groonga::Context.new database = context.create_database Modified: test/test-database.rb (+1 -2) =================================================================== --- test/test-database.rb 2018-01-29 00:24:22 +0900 (c5e6609c) +++ test/test-database.rb 2018-01-29 00:30:25 +0900 (4dceb572) @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2015 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2009-2018 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2016 Masafumi Yokoyama <yokoyama �� clear-code.com> # # This library is free software; you can redistribute it and/or @@ -30,7 +30,6 @@ class DatabaseTest < Test::Unit::TestCase end def test_temporary - Groonga::Logger.register(nil) before_files = @tmp_dir.children database = Groonga::Database.create assert_nil(database.name) Modified: test/test-logger.rb (+13 -1) =================================================================== --- test/test-logger.rb 2018-01-29 00:24:22 +0900 (7438d7c7) +++ test/test-logger.rb 2018-01-29 00:30:25 +0900 (fb175432) @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2010-2018 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2016 Masafumi Yokoyama <yokoyama �� clear-code.com> # # This library is free software; you can redistribute it and/or @@ -19,11 +19,13 @@ class LoggerTest < Test::Unit::TestCase def setup @default_log_path = Groonga::Logger.path + @default_log_max_level = Groonga::Logger.max_level @default_rotate_threshold_size = Groonga::Logger.rotate_threshold_size end def teardown Groonga::Logger.path = @default_log_path + Groonga::Logger.max_level = @default_log_max_level Groonga::Logger.rotate_threshold_size = @default_rotate_threshold_size end @@ -53,6 +55,15 @@ class LoggerTest < Test::Unit::TestCase end sub_test_case ".log" do + setup do + GC.disable + end + + teardown do + Groonga::Logger.unregister + GC.enable + end + test "no options" do messages = [] Groonga::Logger.register do |event, level, time, title, message, location| @@ -141,6 +152,7 @@ class LoggerTest < Test::Unit::TestCase def test_rotate_threshold_size Groonga::Logger.unregister Groonga::Logger.path = @log_path.to_s + Groonga::Logger.reopen Groonga::Logger.rotate_threshold_size = 10 assert_equal([], Dir.glob("#{@log_path}.*")) Groonga::Logger.log("Hello") Modified: test/test-query-logger.rb (+2 -1) =================================================================== --- test/test-query-logger.rb 2018-01-29 00:24:22 +0900 (b5089fbf) +++ test/test-query-logger.rb 2018-01-29 00:30:25 +0900 (c1362455) @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2015-2018 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -141,6 +141,7 @@ class QueryLoggerTest < Test::Unit::TestCase def test_rotate_threshold_size Groonga::QueryLogger.unregister Groonga::QueryLogger.path = @query_log_path.to_s + Groonga::QueryLogger.reopen Groonga::QueryLogger.rotate_threshold_size = 10 assert_equal([], Dir.glob("#{@query_log_path}.*")) Groonga::QueryLogger.log("command") -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180129/f31ac4a8/attachment-0001.htm