add test for process error codes

This commit is contained in:
Emil Tin 2012-09-28 15:29:13 +02:00
parent 4c02542dc5
commit 334f02d7f8
7 changed files with 49 additions and 9 deletions

View File

@ -3,4 +3,5 @@ source "http://rubygems.org"
gem "cucumber"
gem "rake"
gem "osmlib-base"
gem "sys-proctable"
gem "sys-proctable"
gem "rspec-expectations"

View File

@ -14,6 +14,8 @@ GEM
json (1.6.5)
osmlib-base (0.1.4)
rake (0.9.2.2)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
sys-proctable (0.9.1)
term-ansicolor (1.0.7)
@ -24,4 +26,5 @@ DEPENDENCIES
cucumber
osmlib-base
rake
rspec-expectations
sys-proctable

View File

@ -3,14 +3,25 @@ Feature: Handle bad data in a graceful manner
Scenario: Empty dataset
Given the node map
| a | b |
| |
Given the ways
| nodes |
When I route I should get
| from | to | route |
| a | b | |
When I preprocess data
Then preparing should return code 255
Scenario: Only dead-end oneways
Given the node map
| a | b | c |
Given the ways
| nodes | oneway |
| ab | yes |
| cb | yes |
When I preprocess data
Then preparing should return code 255
Scenario: Start/end point at the same location
Given the node map
@ -29,7 +40,7 @@ Feature: Handle bad data in a graceful manner
| 2 | 2 | |
@poles
Scenario: No routing close to the north/south pole
Scenario: Routing close to the north/south pole
Mercator is undefined close to the poles.
All nodes and request with latitude to close to either of the poles should therefore be ignored.

View File

@ -0,0 +1,15 @@
When /^I preprocess data$/ do
begin
osrm_kill
reprocess
rescue OSRMError => e
@process_error = e
end
end
Then /^preparing should return code (\d+)$/ do |code|
@process_error.class.should == OSRMError
@process_error.process.should == 'osrm-prepare'
@process_error.code.to_i.should == code.to_i
end

View File

@ -176,7 +176,7 @@ def reprocess
log "== Extracting #{@osm_file}.osm...", :preprocess
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
log "*** Exited with code #{$?.exitstatus}.", :preprocess
raise "*** osrm-extract exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
raise OSRMError.new 'osrm-extract', $?.exitstatus, "*** osrm-extract exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
end
log '', :preprocess
end
@ -185,7 +185,7 @@ def reprocess
log "== Preparing #{@osm_file}.osm...", :preprocess
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
log "*** Exited with code #{$?.exitstatus}.", :preprocess
raise "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
raise OSRMError.new 'osrm-prepare', $?.exitstatus, "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
end
log '', :preprocess
end
@ -193,4 +193,3 @@ def reprocess
write_server_ini
end
end

1
features/support/env.rb Normal file
View File

@ -0,0 +1 @@
require 'rspec/expectations'

View File

@ -0,0 +1,10 @@
class OSRMError < StandardError
attr_accessor :process, :code, :msg
def initialize process, code, msg
@process = process
@code = code
@msg = msg
end
end