Skip to content

Commit

Permalink
Add --testee option to choose groonga or groonga-httpd as testee
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jul 9, 2012
1 parent 6a8277a commit 8310233
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions lib/groonga/tester.rb
Expand Up @@ -73,6 +73,18 @@ def create_option_parser(tester, tag)
tester.protocol = protocol
end

available_testees = ["groonga", "groonga-httpd"]
available_testee_labels = available_testees.join(", ")
parser.on("--testee=TESTEE", available_testees,
"Test against TESTEE",
"[#{available_testee_labels}]",
"(#{tester.testee})") do |testee|
tester.testee = testee
if tester.testee == "groonga-httpd"
tester.protocol = "http"
end
end

parser.on("--base-directory=DIRECTORY",
"Use DIRECTORY as a base directory of relative path",
"(#{tester.base_directory})") do |directory|
Expand Down Expand Up @@ -117,15 +129,17 @@ def create_option_parser(tester, tag)
end
end

attr_accessor :groonga, :groonga_httpd, :groonga_suggest_create_dataset, :protocol
attr_accessor :groonga, :groonga_httpd, :groonga_suggest_create_dataset
attr_accessor :protocol, :testee
attr_accessor :base_directory, :diff, :diff_options
attr_accessor :gdb, :default_gdb
attr_writer :keep_database
def initialize
@groonga = "groonga"
@groonga_httpd = nil
@groonga_httpd = "groonga-httpd"
@groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
@protocol = :gqtp
@testee = "groonga"
@base_directory = "."
detect_suitable_diff
initialize_debuggers
Expand Down Expand Up @@ -406,9 +420,10 @@ def run_groonga_http(context)
yield(executor)
ensure
begin
if @tester.groonga_httpd.nil?
case @tester.testee
when "groonga"
executor.send_command("shutdown")
else
when "groonga-httpd"
command_line.concat(["-s", "quit"])
system(*command_line)
end
Expand All @@ -430,7 +445,8 @@ def wait_groonga_http_shutdown(pid_file)
end

def groonga_http_command(host, port, pid_file, context)
if @tester.groonga_httpd.nil?
case @tester.testee
when "groonga"
command_line = [
@tester.groonga,
"--pid-path", pid_file.path,
Expand All @@ -440,7 +456,7 @@ def groonga_http_command(host, port, pid_file, context)
"-d",
"-n", context.db_path,
]
else
when "groonga-httpd"
db_path = context.db_path
config_file = create_config_file(host, port, db_path, pid_file)
command_line = [
Expand Down

0 comments on commit 8310233

Please sign in to comment.