Navigation Menu

Skip to content

Commit

Permalink
run-regression-test: support loading data by Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Sep 7, 2018
1 parent 688f4c0 commit 4a5150d
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions lib/groonga-query-log/command/run-regression-test.rb
Expand Up @@ -277,16 +277,28 @@ def ensure_database
return if @database_path.exist?
FileUtils.mkdir_p(@database_path.dirname.to_s)
system(@groonga, "-n", @database_path.to_s, "quit")
grn_files.each do |grn_file|
command = [
@groonga,
"--log-path", log_path.to_s,
"--file", grn_file.to_s,
@database_path.to_s,
]
load_files.each do |load_file|
if load_file.extname == ".rb"
env = {
"GROONGA_LOG_PATH" => log_path.to_s,
}
command = [
RbConfig.ruby,
load_file.to_s,
@database_path.to_s,
]
else
env = {}
command = [
@groonga,
"--log-path", log_path.to_s,
"--file", grn_file.to_s,
@database_path.to_s,
]
end
command_line = command.join(" ")
puts("Running...: #{command_line}")
pid = spawn(*command)
pid = spawn(env, *command)
begin
pid, status = Process.waitpid2(pid)
rescue Interrupt
Expand Down Expand Up @@ -336,23 +348,23 @@ def send_command(name)
end
end

def grn_files
def load_files
files = schema_files
files += data_files if @options[:load_data]
files += index_files
files
end

def schema_files
Pathname.glob("#{@input_directory}/schema/**/*.grn").sort
Pathname.glob("#{@input_directory}/schema/**/*.{grn,rb}").sort
end

def index_files
Pathname.glob("#{@input_directory}/indexes/**/*.grn").sort
Pathname.glob("#{@input_directory}/indexes/**/*.{grn,rb}").sort
end

def data_files
Pathname.glob("#{@input_directory}/data/**/*.grn").sort
Pathname.glob("#{@input_directory}/data/**/*.{grn,rb}").sort
end
end

Expand Down

0 comments on commit 4a5150d

Please sign in to comment.