cuke: test options for osrm-extract and osrm-prepare
This commit is contained in:
+36
-36
@@ -2,20 +2,6 @@ require 'OSM/objects' #osmlib gem
|
||||
require 'OSM/Database'
|
||||
require 'builder'
|
||||
|
||||
OSM_USER = 'osrm'
|
||||
OSM_GENERATOR = 'osrm-test'
|
||||
OSM_UID = 1
|
||||
TEST_FOLDER = 'test'
|
||||
DATA_FOLDER = 'cache'
|
||||
OSM_TIMESTAMP = '2000-00-00T00:00:00Z'
|
||||
DEFAULT_SPEEDPROFILE = 'bicycle'
|
||||
WAY_SPACING = 100
|
||||
DEFAULT_GRID_SIZE = 100 #meters
|
||||
PROFILES_PATH = '../profiles'
|
||||
BIN_PATH = '../build'
|
||||
DEFAULT_INPUT_FORMAT = 'osm'
|
||||
DEFAULT_ORIGIN = [1,1]
|
||||
|
||||
class Location
|
||||
attr_accessor :lon,:lat
|
||||
|
||||
@@ -252,30 +238,44 @@ def write_timestamp
|
||||
File.open( "#{@osm_file}.osrm.timestamp", 'w') {|f| f.write(OSM_TIMESTAMP) }
|
||||
end
|
||||
|
||||
def reprocess
|
||||
def pbf?
|
||||
input_format=='pbf'
|
||||
end
|
||||
def write_input_data
|
||||
Dir.chdir TEST_FOLDER do
|
||||
use_pbf = (input_format=='pbf')
|
||||
write_osm
|
||||
write_timestamp
|
||||
convert_osm_to_pbf if use_pbf
|
||||
unless extracted?
|
||||
log_preprocess_info
|
||||
log "== Extracting #{@osm_file}.osm...", :preprocess
|
||||
unless system "#{BIN_PATH}/osrm-extract #{@osm_file}.osm#{'.pbf' if use_pbf} --profile #{PROFILES_PATH}/#{@profile}.lua 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
||||
end
|
||||
log '', :preprocess
|
||||
end
|
||||
unless prepared?
|
||||
log_preprocess_info
|
||||
log "== Preparing #{@osm_file}.osm...", :preprocess
|
||||
unless system "#{BIN_PATH}/osrm-prepare #{@osm_file}.osrm --profile #{PROFILES_PATH}/#{@profile}.lua 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
||||
end
|
||||
log '', :preprocess
|
||||
end
|
||||
log_preprocess_done
|
||||
convert_osm_to_pbf if pbf?
|
||||
end
|
||||
end
|
||||
|
||||
def extract_data
|
||||
Dir.chdir TEST_FOLDER do
|
||||
log_preprocess_info
|
||||
log "== Extracting #{@osm_file}.osm...", :preprocess
|
||||
unless system "#{BIN_PATH}/osrm-extract #{@osm_file}.osm#{'.pbf' if pbf?} --profile #{PROFILES_PATH}/#{@profile}.lua 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
||||
end
|
||||
log '', :preprocess
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_data
|
||||
Dir.chdir TEST_FOLDER do
|
||||
log_preprocess_info
|
||||
log "== Preparing #{@osm_file}.osm...", :preprocess
|
||||
unless system "#{BIN_PATH}/osrm-prepare #{@osm_file}.osrm --profile #{PROFILES_PATH}/#{@profile}.lua 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
||||
end
|
||||
log '', :preprocess
|
||||
end
|
||||
end
|
||||
|
||||
def reprocess
|
||||
write_input_data
|
||||
extract_data unless extracted?
|
||||
prepare_data unless prepared?
|
||||
log_preprocess_done
|
||||
end
|
||||
|
||||
@@ -3,6 +3,22 @@ require 'rspec/expectations'
|
||||
DEFAULT_PORT = 5000
|
||||
DEFAULT_TIMEOUT = 2
|
||||
|
||||
ROOT_FOLDER = Dir.pwd
|
||||
OSM_USER = 'osrm'
|
||||
OSM_GENERATOR = 'osrm-test'
|
||||
OSM_UID = 1
|
||||
TEST_FOLDER = File.join ROOT_FOLDER, 'test'
|
||||
DATA_FOLDER = 'cache'
|
||||
OSM_TIMESTAMP = '2000-00-00T00:00:00Z'
|
||||
DEFAULT_SPEEDPROFILE = 'bicycle'
|
||||
WAY_SPACING = 100
|
||||
DEFAULT_GRID_SIZE = 100 #meters
|
||||
PROFILES_PATH = File.join ROOT_FOLDER, 'profiles'
|
||||
BIN_PATH = File.join ROOT_FOLDER, 'build'
|
||||
DEFAULT_INPUT_FORMAT = 'osm'
|
||||
DEFAULT_ORIGIN = [1,1]
|
||||
|
||||
|
||||
puts "Ruby version #{RUBY_VERSION}"
|
||||
unless RUBY_VERSION.to_f >= 1.9
|
||||
raise "*** Please upgrade to Ruby 1.9.x to run the OSRM cucumber tests"
|
||||
@@ -24,6 +40,10 @@ else
|
||||
puts "Using default timeout #{OSRM_TIMEOUT}"
|
||||
end
|
||||
|
||||
unless File.exists? TEST_FOLDER
|
||||
raise "*** Test folder #{TEST_FOLDER} doesn't exist."
|
||||
end
|
||||
|
||||
|
||||
AfterConfiguration do |config|
|
||||
clear_log_files
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
def run_bin bin, options
|
||||
Dir.chdir TEST_FOLDER do
|
||||
opt = options.dup
|
||||
|
||||
if opt.include? '{base}'
|
||||
raise "*** {base} is missing" unless @osm_file
|
||||
opt.gsub! "{base}", "#{@osm_file}"
|
||||
end
|
||||
|
||||
if opt.include? '{profile}'
|
||||
opt.gsub! "{profile}", "#{PROFILES_PATH}/#{@profile}.lua"
|
||||
end
|
||||
|
||||
@stdout = `#{BIN_PATH}/#{bin} #{opt} 2>error.log`
|
||||
@stderr = File.read 'error.log'
|
||||
@exit_code = $?.exitstatus
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user