diff --git a/features/options/options.feature b/features/options/options.feature new file mode 100644 index 000000000..ef04f3f7c --- /dev/null +++ b/features/options/options.feature @@ -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 []:" + 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 []:" + 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" \ No newline at end of file diff --git a/features/step_definitions/locate.rb b/features/step_definitions/locate.rb index 3b1d5d7da..9d3d74f65 100644 --- a/features/step_definitions/locate.rb +++ b/features/step_definitions/locate.rb @@ -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 diff --git a/features/step_definitions/nearest.rb b/features/step_definitions/nearest.rb index 352f6bc89..ae5a79cf5 100644 --- a/features/step_definitions/nearest.rb +++ b/features/step_definitions/nearest.rb @@ -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 diff --git a/features/step_definitions/options.rb b/features/step_definitions/options.rb new file mode 100644 index 000000000..3e72d65ff --- /dev/null +++ b/features/step_definitions/options.rb @@ -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 diff --git a/features/step_definitions/requests.rb b/features/step_definitions/requests.rb index c84ff7110..e6bdcae84 100644 --- a/features/step_definitions/requests.rb +++ b/features/step_definitions/requests.rb @@ -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 diff --git a/features/step_definitions/routability.rb b/features/step_definitions/routability.rb index 6c5148b14..6305fc1ea 100644 --- a/features/step_definitions/routability.rb +++ b/features/step_definitions/routability.rb @@ -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 = [] diff --git a/features/step_definitions/routing.rb b/features/step_definitions/routing.rb index ead847166..8040719e7 100644 --- a/features/step_definitions/routing.rb +++ b/features/step_definitions/routing.rb @@ -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'] diff --git a/features/support/launch.rb b/features/support/launch.rb index 8a80a0492..125bb919d 100644 --- a/features/support/launch.rb +++ b/features/support/launch.rb @@ -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