Kouhei Sutou
null+****@clear*****
Fri May 6 14:37:55 JST 2016
Kouhei Sutou 2016-05-06 14:37:55 +0900 (Fri, 06 May 2016) New Revision: 015bc01bcff6b783894fb3cd87c61276c1689a1b https://github.com/groonga/grntest/commit/015bc01bcff6b783894fb3cd87c61276c1689a1b Message: Add timeout directive Modified files: lib/grntest/executors/base-executor.rb lib/grntest/executors/standard-io-executor.rb Modified: lib/grntest/executors/base-executor.rb (+31 -1) =================================================================== --- lib/grntest/executors/base-executor.rb 2016-04-27 15:32:54 +0900 (345fe0c) +++ lib/grntest/executors/base-executor.rb 2016-05-06 14:37:55 +0900 (8f22a75) @@ -39,6 +39,7 @@ module Grntest @pending_load_command = nil @current_command_name = nil @output_type = nil + @timeout = default_timeout @long_timeout = default_long_timeout @context = context @custom_important_log_levels = [] @@ -183,6 +184,29 @@ module Grntest FileUtils.cp_r(source.to_s, destination.to_s) end + def execute_directive_timeout(line, content, options) + timeout, = options + invalid_value_p = false + case timeout + when "default" + @timeout = default_timeout + when nil + invalid_value_p = true + else + begin + @timeout = Float(timeout) + rescue ArgumentError + invalid_value_p = true + end + end + + if invalid_value_p + log_input(line) + message = "timeout must be number or 'default': <#{timeout}>" + log_error("#|e| [timeout] #{message}") + end + end + def execute_directive_long_timeout(line, content, options) long_timeout, = options invalid_value_p = false @@ -275,6 +299,8 @@ module Grntest execute_directive_include(line, content, options) when "copy-path" execute_directive_copy_path(line, content, options) + when "timeout" + execute_directive_timeout(line, content, options) when "long-timeout" execute_directive_long_timeout(line, content, options) when "on-error" @@ -373,7 +399,7 @@ module Grntest def read_all_readable_content(output, options={}) content = "" - first_timeout = options[:first_timeout] || 5 + first_timeout = options[:first_timeout] || @timeout timeout = first_timeout while IO.select([output], [], [], timeout) break if output.eof? @@ -458,6 +484,10 @@ module Grntest end end + def default_timeout + 3 + end + def default_long_timeout 180 end Modified: lib/grntest/executors/standard-io-executor.rb (+0 -2) =================================================================== --- lib/grntest/executors/standard-io-executor.rb 2016-04-27 15:32:54 +0900 (408c82c) +++ lib/grntest/executors/standard-io-executor.rb 2016-05-06 14:37:55 +0900 (9fac4e1) @@ -57,8 +57,6 @@ module Grntest options = {} if may_slow_command?(command) options[:first_timeout] = @long_timeout - elsif command.name == "dump" - options[:first_timeout] = 0.1 end read_all_readable_content(@output, options) end -------------- next part -------------- HTML����������������������������... 下載