[Groonga-commit] groonga/groonga-query-log at 4e7a2dc [master] Exit in bin/ scripts

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jun 2 16:12:00 JST 2014


Kouhei Sutou	2014-06-02 16:12:00 +0900 (Mon, 02 Jun 2014)

  New Revision: 4e7a2dcdce570e670358d75c3c3b93cca6849182
  https://github.com/groonga/groonga-query-log/commit/4e7a2dcdce570e670358d75c3c3b93cca6849182

  Message:
    Exit in bin/ scripts

  Modified files:
    bin/groonga-query-log-analyze
    bin/groonga-query-log-detect-memory-leak
    bin/groonga-query-log-extract
    bin/groonga-query-log-replay
    bin/groonga-query-log-run-regression-test
    bin/groonga-query-log-verify-server
    lib/groonga/query-log/analyzer.rb
    lib/groonga/query-log/command/detect-memory-leak.rb
    lib/groonga/query-log/command/replay.rb
    lib/groonga/query-log/command/run-regression-test.rb
    lib/groonga/query-log/command/verify-server.rb
    lib/groonga/query-log/extractor.rb

  Modified: bin/groonga-query-log-analyze (+2 -6)
===================================================================
--- bin/groonga-query-log-analyze    2014-06-02 15:51:25 +0900 (bf3f08d)
+++ bin/groonga-query-log-analyze    2014-06-02 16:12:00 +0900 (c62642e)
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 #
 # Copyright (C) 2012  Haruka Yoshihara <yoshihara �� clear-code.com>
+# Copyright (C) 2014  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
@@ -20,9 +21,4 @@
 require "groonga/query-log"
 
 analyzer = Groonga::QueryLog::Analyzer.new
-begin
-  analyzer.run(*ARGV)
-rescue Groonga::QueryLog::Analyzer::Error
-  $stderr.puts($!.message)
-  exit(false)
-end
+exit(analyzer.run(ARGV))

  Modified: bin/groonga-query-log-detect-memory-leak (+2 -2)
===================================================================
--- bin/groonga-query-log-detect-memory-leak    2014-06-02 15:51:25 +0900 (ccf3cb5)
+++ bin/groonga-query-log-detect-memory-leak    2014-06-02 16:12:00 +0900 (605e333)
@@ -1,7 +1,7 @@
 #!/usr/bin/env ruby
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2013-2014  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
@@ -20,4 +20,4 @@
 require "groonga/query-log/command/detect-memory-leak"
 
 detect_memory_leak_command = Groonga::QueryLog::Command::DetectMemoryLeak.new
-detect_memory_leak_command.run(*ARGV)
+exit(detect_memory_leak_command.run(ARGV))

  Modified: bin/groonga-query-log-extract (+2 -7)
===================================================================
--- bin/groonga-query-log-extract    2014-06-02 15:51:25 +0900 (308a3f3)
+++ bin/groonga-query-log-extract    2014-06-02 16:12:00 +0900 (958a66e)
@@ -1,7 +1,7 @@
 #!/usr/bin/env ruby
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2011  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2011-2014  Kouhei Sutou <kou �� clear-code.com>
 # Copyright (C) 2012  Haruka Yoshihara <yoshihara �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
@@ -20,9 +20,4 @@
 require "groonga/query-log/extractor"
 
 extracter = Groonga::QueryLog::Extractor.new
-begin
-  extracter.run(*ARGV)
-rescue Groonga::QueryLog::Extractor::Error
-  $stderr.puts($!.message)
-  exit(false)
-end
+exit(extracter.run(*ARGV))

  Modified: bin/groonga-query-log-replay (+2 -2)
===================================================================
--- bin/groonga-query-log-replay    2014-06-02 15:51:25 +0900 (f758675)
+++ bin/groonga-query-log-replay    2014-06-02 16:12:00 +0900 (1e7b747)
@@ -1,7 +1,7 @@
 #!/usr/bin/env ruby
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2013-2014  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
@@ -20,4 +20,4 @@
 require "groonga/query-log/command/replay"
 
 replay_command = Groonga::QueryLog::Command::Replay.new
-replay_command.run(*ARGV)
+exit(replay_command.run(ARGV))

  Modified: bin/groonga-query-log-run-regression-test (+1 -1)
===================================================================
--- bin/groonga-query-log-run-regression-test    2014-06-02 15:51:25 +0900 (c4db8d5)
+++ bin/groonga-query-log-run-regression-test    2014-06-02 16:12:00 +0900 (85223fe)
@@ -20,4 +20,4 @@
 require "groonga/query-log/command/run-regression-test"
 
 command = Groonga::QueryLog::Command::RunRegressionTest.new
-command.run(*ARGV)
+exit(command.run(ARGV))

  Modified: bin/groonga-query-log-verify-server (+2 -2)
===================================================================
--- bin/groonga-query-log-verify-server    2014-06-02 15:51:25 +0900 (89150ae)
+++ bin/groonga-query-log-verify-server    2014-06-02 16:12:00 +0900 (3cea18b)
@@ -1,7 +1,7 @@
 #!/usr/bin/env ruby
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2013-2014  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
@@ -20,4 +20,4 @@
 require "groonga/query-log/command/verify-server"
 
 verify_server_command = Groonga::QueryLog::Command::VerifyServer.new
-verify_server_command.run(*ARGV)
+exit(verify_server_command.run(ARGV))

  Modified: lib/groonga/query-log/analyzer.rb (+8 -6)
===================================================================
--- lib/groonga/query-log/analyzer.rb    2014-06-02 15:51:25 +0900 (1182499)
+++ lib/groonga/query-log/analyzer.rb    2014-06-02 16:12:00 +0900 (476fe9b)
@@ -57,7 +57,7 @@ module Groonga
       # @param [Array<String>] arguments arguments for
       #   groonga-query-log-analyze. Please execute
       #   "groonga-query-log-analyze --help" or see #setup_options.
-      def run(*arguments)
+      def run(arguments)
         log_paths = @option_parser.parse!(arguments)
 
         stream = @options[:stream]
@@ -89,13 +89,15 @@ module Groonga
 
         if stream
           streamer.finish
-          return
+        else
+          statistics.replace(full_statistics) unless dynamic_sort
+
+          reporter = create_reporter(statistics)
+          reporter.apply_options(@options)
+          reporter.report
         end
-        statistics.replace(full_statistics) unless dynamic_sort
 
-        reporter = create_reporter(statistics)
-        reporter.apply_options(@options)
-        reporter.report
+        true
       end
 
       private

  Modified: lib/groonga/query-log/command/detect-memory-leak.rb (+4 -3)
===================================================================
--- lib/groonga/query-log/command/detect-memory-leak.rb    2014-06-02 15:51:25 +0900 (734c4c0)
+++ lib/groonga/query-log/command/detect-memory-leak.rb    2014-06-02 16:12:00 +0900 (20a7319)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2013-2014  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
@@ -28,14 +28,15 @@ module Groonga
           @options = MemoryLeakDetector::Options.new
         end
 
-        def run(*command_line)
-          input_paths = create_parser.parse(*command_line)
+        def run(command_line)
+          input_paths = create_parser.parse(command_line)
           detector = MemoryLeakDetector.new(@options)
           input_paths.each do |input_path|
             File.open(input_path) do |input|
               detector.detect(input)
             end
           end
+          true
         end
 
         private

  Modified: lib/groonga/query-log/command/replay.rb (+4 -3)
===================================================================
--- lib/groonga/query-log/command/replay.rb    2014-06-02 15:51:25 +0900 (0edecde)
+++ lib/groonga/query-log/command/replay.rb    2014-06-02 16:12:00 +0900 (8de322c)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2013-2014  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
@@ -28,14 +28,15 @@ module Groonga
           @options = Replayer::Options.new
         end
 
-        def run(*command_line)
-          input_paths = create_parser.parse(*command_line)
+        def run(command_line)
+          input_paths = create_parser.parse(command_line)
           replayer = Replayer.new(@options)
           input_paths.each do |input_path|
             File.open(input_path) do |input|
               replayer.replay(input)
             end
           end
+          true
         end
 
         private

  Modified: lib/groonga/query-log/command/run-regression-test.rb (+7 -5)
===================================================================
--- lib/groonga/query-log/command/run-regression-test.rb    2014-06-02 15:51:25 +0900 (434e8e0)
+++ lib/groonga/query-log/command/run-regression-test.rb    2014-06-02 16:12:00 +0900 (4428dda)
@@ -44,7 +44,7 @@ module Groonga
           @skip_finished_queries = false
         end
 
-        def run(*command_line)
+        def run(command_line)
           option_parser = create_option_parser
           begin
             option_parser.parse!(command_line)
@@ -299,14 +299,16 @@ module Groonga
               end
             end
 
-            old_thread.join
-            new_thread.join
+            old_thread_success = old_thread.value
+            new_thread_success = new_thread.value
+
+            old_thread_success and new_thread_success
           end
 
           private
           def run_test
             @n_ready_waits -= 1
-            return unless @n_ready_waits.zero?
+            return true unless @n_ready_waits.zero?
 
             @clone_pids.each do |pid|
               Process.waitpid(pid)
@@ -358,7 +360,7 @@ module Groonga
               query_log_path.to_s,
             ]
             verify_serer = VerifyServer.new
-            verify_serer.run(*command_line)
+            verify_serer.run(command_line)
           end
 
           def query_log_paths

  Modified: lib/groonga/query-log/command/verify-server.rb (+4 -3)
===================================================================
--- lib/groonga/query-log/command/verify-server.rb    2014-06-02 15:51:25 +0900 (5f7ecef)
+++ lib/groonga/query-log/command/verify-server.rb    2014-06-02 16:12:00 +0900 (bb95601)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2013-2014  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
@@ -28,8 +28,8 @@ module Groonga
           @options = ServerVerifier::Options.new
         end
 
-        def run(*command_line)
-          input_paths = create_parser.parse(*command_line)
+        def run(command_line)
+          input_paths = create_parser.parse(command_line)
           verifier = ServerVerifier.new(@options)
           if input_paths.empty?
             verifier.verify($stdin)
@@ -40,6 +40,7 @@ module Groonga
               end
             end
           end
+          true
         end
 
         private

  Modified: lib/groonga/query-log/extractor.rb (+7 -6)
===================================================================
--- lib/groonga/query-log/extractor.rb    2014-06-02 15:51:25 +0900 (3483ba6)
+++ lib/groonga/query-log/extractor.rb    2014-06-02 16:12:00 +0900 (1e36f54)
@@ -31,9 +31,6 @@ module Groonga
       class Error < StandardError
       end
 
-      class NoInputError < Error
-      end
-
       attr_accessor :options
       attr_reader :option_parser
 
@@ -58,16 +55,18 @@ module Groonga
       # @param [Array<String>] arguments arguments for
       #   groonga-query-log-extract. Please execute
       #   "groonga-query-log-extract --help" or see #setup_options.
-      def run(*arguments)
+      def run(arguments)
         begin
           log_paths = @option_parser.parse!(arguments)
         rescue OptionParser::ParseError
-          raise(ArgumentError, $!.message)
+          $stderr.puts($!.message)
+          return false
         end
 
         if log_paths.empty?
           unless log_via_stdin?
-            raise(NoInputError, "Error: Please specify input log files.")
+            $stderr.puts("Error: Please specify input log files.")
+            return false
           end
           log = $stdin
         else
@@ -81,6 +80,8 @@ module Groonga
         else
           extract(log, $stdout)
         end
+
+        true
       end
 
       private
-------------- next part --------------
HTML����������������������������...
다운로드 



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