Navigation Menu

Skip to content

Commit

Permalink
Use suitable name: --protocol -> --interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 11, 2012
1 parent f1d9368 commit 6b137a2
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions lib/grntest/tester.rb
Expand Up @@ -63,13 +63,13 @@ def create_option_parser(tester, tag)
tester.groonga_suggest_create_dataset = command
end

available_protocols = [:gqtp, :http]
available_protocol_labels = available_protocols.join(", ")
parser.on("--protocol=PROTOCOL", available_protocols,
"Use PROTOCOL for communicating groonga",
"[#{available_protocol_labels}]",
"(#{tester.protocol})") do |protocol|
tester.protocol = protocol
available_interfaces = [:stdio, :http]
available_interface_labels = available_interfaces.join(", ")
parser.on("--interface=INTERFACE", available_interfaces,
"Use INTERFACE for communicating groonga",
"[#{available_interface_labels}]",
"(#{tester.interface})") do |interface|
tester.interface = interface
end

available_testees = ["groonga", "groonga-httpd"]
Expand All @@ -80,7 +80,7 @@ def create_option_parser(tester, tag)
"(#{tester.testee})") do |testee|
tester.testee = testee
if tester.testee == "groonga-httpd"
tester.protocol = :http
tester.interface = :http
end
end

Expand Down Expand Up @@ -191,7 +191,7 @@ def parse_name_or_pattern(name)
end

attr_accessor :groonga, :groonga_httpd, :groonga_suggest_create_dataset
attr_accessor :protocol, :testee
attr_accessor :interface, :testee
attr_accessor :base_directory, :diff, :diff_options
attr_accessor :n_workers
attr_accessor :output
Expand All @@ -203,7 +203,7 @@ def initialize
@groonga = "groonga"
@groonga_httpd = "groonga-httpd"
@groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
@protocol = :gqtp
@interface = :stdio
@testee = "groonga"
@base_directory = "."
@reporter = nil
Expand Down Expand Up @@ -697,15 +697,15 @@ def keep_database_path
end

def run_groonga(context, &block)
case @tester.protocol
when :gqtp
run_groonga_gqtp(context, &block)
case @tester.interface
when :stdio
run_groonga_stdio(context, &block)
when :http
run_groonga_http(context, &block)
end
end

def run_groonga_gqtp(context)
def run_groonga_stdio(context)
pid = nil
begin
open_pipe do |input_read, input_write, output_read, output_write|
Expand All @@ -726,7 +726,9 @@ def run_groonga_gqtp(context)
output_fd => output_fd
}
pid = Process.spawn(env, *command_line, options)
executor = GQTPExecutor.new(groonga_input, groonga_output, context)
executor = StandardIOExecutor.new(groonga_input,
groonga_output,
context)
executor.ensure_groonga_ready
yield(executor)
end
Expand Down Expand Up @@ -832,7 +834,7 @@ def groonga_http_command(host, port, pid_file, context)
"--pid-path", pid_file.path,
"--bind-address", host,
"--port", port.to_s,
"--protocol", @tester.protocol.to_s,
"--protocol", "http",
"--log-path", context.log_path,
"-d",
"-n", context.db_path,
Expand Down Expand Up @@ -1239,7 +1241,7 @@ def log_error(content)
end
end

class GQTPExecutor < Executor
class StandardIOExecutor < Executor
def initialize(input, output, context=nil)
super(context)
@input = input
Expand Down

0 comments on commit 6b137a2

Please sign in to comment.