cuke: test options for osrm-extract and osrm-prepare

This commit is contained in:
Emil Tin
2014-04-21 15:24:42 +02:00
committed by Dennis Luxen
parent fc6607ce9e
commit a12209e61d
21 changed files with 392 additions and 83 deletions
+25
View File
@@ -133,3 +133,28 @@ Given /^the input file ([^"]*)$/ do |file|
raise "*** Input file must in .osm format" unless File.extname(file)=='.osm'
@osm_str = File.read file
end
Given /^the data has been saved to disk$/ do
begin
write_input_data
rescue OSRMError => e
@process_error = e
end
end
Given /^the data has been extracted$/ do
begin
write_input_data
extract_data unless extracted?
rescue OSRMError => e
@process_error = e
end
end
Given /^the data has been prepared$/ do
begin
reprocess
rescue OSRMError => e
@process_error = e
end
end
+12 -18
View File
@@ -1,25 +1,19 @@
When(/^I run "osrm\-routed\s?(.*?)"$/) do |options|
Dir.chdir TEST_FOLDER do
if options.include? '{base}'
# expand {base} to base path of preprocessed data file
raise "*** Cannot expand {base} without a preprocessed file." unless @osm_file
options_expanded = options.gsub "{base}", "#{@osm_file}"
else
options_expanded = options
end
begin
Timeout.timeout(1) do
@stdout = `#{BIN_PATH}/osrm-routed #{options_expanded} 2>error.log`
@stderr = File.read 'error.log'
@exit_code = $?.exitstatus
end
rescue Timeout::Error
raise "*** osrm-routed didn't quit. Maybe the --trial option wasn't used?"
end
begin
Timeout.timeout(1) { run_bin 'osrm-routed', options }
rescue Timeout::Error
raise "*** osrm-routed didn't quit. Maybe the --trial option wasn't used?"
end
end
When(/^I run "osrm\-extract\s?(.*?)"$/) do |options|
run_bin 'osrm-extract', options
end
When(/^I run "osrm\-prepare\s?(.*?)"$/) do |options|
run_bin 'osrm-prepare', options
end
Then /^it should exit with code (\d+)$/ do |code|
@exit_code.should == code.to_i
end
+1 -9
View File
@@ -29,16 +29,8 @@ Then /^response should be a well-formed route$/ do
@json['via_indices'].class.should == Array
end
When /^I preprocess data$/ do
begin
reprocess
rescue OSRMError => e
@process_error = e
end
end
Then /^"([^"]*)" should return code (\d+)$/ do |binary, code|
@process_error.is_a?(OSRMError).should == true
@process_error.process.should == binary
@process_error.code.to_i.should == code.to_i
end
end