2014-03-19 14:28:24 -04:00
|
|
|
When(/^I run "osrm\-routed\s?(.*?)"$/) do |options|
|
|
|
|
Dir.chdir TEST_FOLDER do
|
2014-03-22 06:36:42 -04:00
|
|
|
if options.include? '{base}'
|
|
|
|
# expand {base} to base path of preprocessed data file
|
2014-03-24 05:16:32 -04:00
|
|
|
raise "*** Cannot expand {base} without a preprocessed file." unless @osm_file
|
|
|
|
options_expanded = options.gsub "{base}", "#{@osm_file}"
|
2014-03-22 06:36:42 -04:00
|
|
|
else
|
|
|
|
options_expanded = options
|
|
|
|
end
|
2014-03-24 05:16:32 -04:00
|
|
|
|
2014-03-19 14:28:24 -04:00
|
|
|
begin
|
|
|
|
Timeout.timeout(1) do
|
2014-03-22 06:36:42 -04:00
|
|
|
@stdout = `#{BIN_PATH}/osrm-routed #{options_expanded} 2>error.log`
|
2014-03-19 14:28:24 -04:00
|
|
|
@stderr = File.read 'error.log'
|
|
|
|
@exit_code = $?.exitstatus
|
|
|
|
end
|
2014-03-22 06:36:42 -04:00
|
|
|
rescue Timeout::Error
|
|
|
|
raise "*** osrm-routed didn't quit. Maybe the --trial option wasn't used?"
|
2014-03-19 14:28:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^it should exit with code (\d+)$/ do |code|
|
|
|
|
@exit_code.should == code.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^stdout should contain "(.*?)"$/ do |str|
|
2014-03-22 06:36:42 -04:00
|
|
|
@stdout.should include(str)
|
2014-03-19 14:28:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
Then /^stderr should contain "(.*?)"$/ do |str|
|
2014-03-22 06:36:42 -04:00
|
|
|
@stderr.should include(str)
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^stdout should contain \/(.*)\/$/) do |regex_str|
|
|
|
|
regex = Regexp.new regex_str
|
|
|
|
@stdout.should =~ regex
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^stderr should contain \/(.*)\/$/) do |regex_str|
|
|
|
|
regex = Regexp.new regex_str
|
|
|
|
@stderr.should =~ regex
|
2014-03-19 14:28:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
Then /^stdout should be empty$/ do
|
|
|
|
@stdout.should == ""
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^stderr should be empty$/ do
|
|
|
|
@stderr.should == ""
|
|
|
|
end
|
2014-03-22 06:36:42 -04:00
|
|
|
|
|
|
|
Then /^stdout should contain (\d+) lines?$/ do |lines|
|
|
|
|
@stdout.lines.count.should == lines.to_i
|
|
|
|
end
|