Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #5 from komainu8/feature/add_new_option
Browse files Browse the repository at this point in the history
Feature/add new option

Patch by komainu8. Thanks!!!
  • Loading branch information
kou committed Apr 12, 2017
2 parents c7139c9 + 7872796 commit 47fec05
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions lib/groonga/query-log/command/run-regression-test.rb
Expand Up @@ -34,9 +34,11 @@ def initialize

@old_groonga = "groonga"
@old_database = "db.old/db"
@old_groonga_options = []

@new_groonga = "groonga"
@new_database = "db.new/db"
@new_groonga_options = []

@recreate_database = false
@load_data = true
Expand Down Expand Up @@ -95,6 +97,13 @@ def create_option_parser
@old_groonga = groonga
end

parser.on("--old-groonga-option=OPTION",
"Add an additional old groonga option",
"You can specify this option multiple times to specify multiple groonga options",
"(no options)") do |groonga_option|
@old_groonga_options << groonga_option
end

parser.separator("")
parser.separator("New Groonga:")
parser.on("--new-groonga=GROONGA",
Expand All @@ -103,6 +112,13 @@ def create_option_parser
@new_groonga = groonga
end

parser.on("--new-groonga-option=OPTION",
"Add an additional new groonga option",
"You can specify this option multiple times to specify multiple groonga options",
"(no options)") do |groonga_option|
@new_groonga_options << groonga_option
end

parser.separator("")
parser.separator("Operations:")
parser.on("--recreate-database",
Expand Down Expand Up @@ -161,22 +177,25 @@ def tester_options

def old_groonga_server
GroongaServer.new(@old_groonga,
@old_groonga_options,
@old_database,
server_options)
end

def new_groonga_server
GroongaServer.new(@new_groonga,
@new_groonga_options,
@new_database,
server_options)
end

class GroongaServer
attr_reader :host, :port
def initialize(groonga, database_path, options)
def initialize(groonga, groonga_options, database_path, options)
@input_directory = options[:input_directory] || Pathname.new(".")
@working_directory = options[:working_directory] || Pathname.new(".")
@groonga = groonga
@groonga_options = groonga_options
@database_path = @working_directory + database_path
@host = "127.0.0.1"
@port = find_unused_port
Expand All @@ -186,12 +205,12 @@ def initialize(groonga, database_path, options)
def run
return unless @options[:run_queries]

arguments = [
"--bind-address", @host,
"--port", @port.to_s,
"--protocol", "http",
"--log-path", log_path.to_s,
]
arguments = @groonga_options.dup

arguments.concat(["--bind-address", @host])
arguments.concat(["--port", @port.to_s])
arguments.concat(["--protocol", "http"])
arguments.concat(["--log-path", log_path.to_s])
if @options[:output_query_log]
arguments.concat(["--query-log-path", query_log_path.to_s])
end
Expand Down

0 comments on commit 47fec05

Please sign in to comment.