cuke: test osrm-routed options

This commit is contained in:
Emil Tin 2014-03-19 19:28:24 +01:00
parent af41c9f6e4
commit c1806476af
8 changed files with 91 additions and 6 deletions

View File

@ -0,0 +1,49 @@
@routing @options
Feature: Command line options
Background:
Given the profile "testbot"
Scenario: No options
When I run "osrm-routed"
Then it should exit with code 0
And stderr should be empty
And stdout should contain "osrm-routed <base.osrm> [<options>]:"
And stdout should contain "Options:"
And stdout should contain "Configuration:"
Scenario: Help
When I run "osrm-routed --help"
Then it should exit with code 0
And stderr should be empty
And stdout should contain "osrm-routed <base.osrm> [<options>]:"
And stdout should contain "Options:"
And stdout should contain "--version"
And stdout should contain "--help"
And stdout should contain "--config"
And stdout should contain "Configuration:"
And stdout should contain "--hsgrdata arg"
And stdout should contain "--nodesdata arg"
And stdout should contain "--edgesdata arg"
And stdout should contain "--ramindex arg"
And stdout should contain "--fileindex arg"
And stdout should contain "--namesdata arg"
And stdout should contain "--timestamp arg"
And stdout should contain "--ip"
And stdout should contain "--port"
And stdout should contain "--threads"
And stdout should contain "--sharedmemory"
@todo
Scenario: Non-existing option
When I run "osrm-routed --fly-me-to-the-moon"
Then it should exit with code 255
Then stdout should be empty
And stderr should contain "unrecognised option '--fly-me-to-the-moon'"
@todo
Scenario: Missing file
When I run "osrm-routed overtherainbow.osrm"
Then it should exit with code 255
Then stdout should be empty
And stderr should contain "missing"

View File

@ -1,7 +1,7 @@
When /^I request locate I should get$/ do |table|
reprocess
actual = []
OSRMLauncher.new("#{@osm_file}.osrm") do
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
table.hashes.each_with_index do |row,ri|
in_node = find_node_by_name row['in']
raise "*** unknown in-node '#{row['in']}" unless in_node

View File

@ -1,7 +1,7 @@
When /^I request nearest I should get$/ do |table|
reprocess
actual = []
OSRMLauncher.new("#{@osm_file}.osrm") do
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
table.hashes.each_with_index do |row,ri|
in_node = find_node_by_name row['in']
raise "*** unknown in-node '#{row['in']}" unless in_node

View File

@ -0,0 +1,36 @@
When(/^I run "osrm\-routed\s?(.*?)"$/) do |options|
Dir.chdir TEST_FOLDER do
begin
Timeout.timeout(1) do
@stdout = `#{BIN_PATH}/osrm-routed #{options} 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
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|
@stdout.include?(str).should == true
end
Then /^stderr should contain "(.*?)"$/ do |str|
@stderr.include?(str).should == true
end
Then /^stdout should be empty$/ do
@stdout.should == ""
end
Then /^stderr should be empty$/ do
@stderr.should == ""
end

View File

@ -1,6 +1,6 @@
When /^I request \/(.*)$/ do |path|
reprocess
OSRMLauncher.new("#{@osm_file}.osrm") do
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
@response = request_path path
end
end

View File

@ -5,7 +5,7 @@ Then /^routability should be$/ do |table|
if table.headers&["forw","backw","bothw"] == []
raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
end
OSRMLauncher.new("#{@osm_file}.osrm") do
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
table.hashes.each_with_index do |row,i|
got = row.dup
attempts = []

View File

@ -1,7 +1,7 @@
When /^I route I should get$/ do |table|
reprocess
actual = []
OSRMLauncher.new("#{@osm_file}.osrm") do
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
table.hashes.each_with_index do |row,ri|
waypoints = []
if row['from'] and row['to']

View File

@ -5,7 +5,7 @@ LAUNCH_TIMEOUT = 2
SHUTDOWN_TIMEOUT = 2
OSRM_ROUTED_LOG_FILE = 'osrm-routed.log'
class OSRMLauncher
class OSRMBackgroundLauncher
def initialize input_file, &block
@input_file = input_file
Dir.chdir TEST_FOLDER do