cuke: test file options
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
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} 2>error.log`
|
||||
@stdout = `#{BIN_PATH}/osrm-routed #{options_expanded} 2>error.log`
|
||||
@stderr = File.read 'error.log'
|
||||
@exit_code = $?.exitstatus
|
||||
end
|
||||
rescue
|
||||
# TODO would be easy to handle there was an option to make osrm exit right after completing initialization
|
||||
@stdout = nil
|
||||
@stderr = nil
|
||||
@exit_code = nil
|
||||
rescue Timeout::Error
|
||||
raise "*** osrm-routed didn't quit. Maybe the --trial option wasn't used?"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -20,11 +25,21 @@ Then /^it should exit with code (\d+)$/ do |code|
|
||||
end
|
||||
|
||||
Then /^stdout should contain "(.*?)"$/ do |str|
|
||||
@stdout.include?(str).should == true
|
||||
@stdout.should include(str)
|
||||
end
|
||||
|
||||
Then /^stderr should contain "(.*?)"$/ do |str|
|
||||
@stderr.include?(str).should == true
|
||||
@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
|
||||
end
|
||||
|
||||
Then /^stdout should be empty$/ do
|
||||
@@ -34,3 +49,7 @@ end
|
||||
Then /^stderr should be empty$/ do
|
||||
@stderr.should == ""
|
||||
end
|
||||
|
||||
Then /^stdout should contain (\d+) lines?$/ do |lines|
|
||||
@stdout.lines.count.should == lines.to_i
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user