make cuke tests work with ruby 2.x
This commit is contained in:
parent
ec7d3a9885
commit
63059cfab3
@ -4,7 +4,7 @@ DEFAULT_PORT = 5000
|
||||
|
||||
|
||||
puts "Ruby version #{RUBY_VERSION}"
|
||||
unless RUBY_VERSION =~ /^1.9/
|
||||
unless RUBY_VERSION.to_f >= 1.9
|
||||
raise "*** Please upgrade to Ruby 1.9.x to run the OSRM cucumber tests"
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
require 'digest/sha1'
|
||||
|
||||
bin_extract_hash = nil
|
||||
profile_hashes = nil
|
||||
|
||||
def hash_of_files paths
|
||||
paths = [paths] unless paths.is_a? Array
|
||||
hash = Digest::SHA1.new
|
||||
@ -16,8 +19,8 @@ end
|
||||
|
||||
|
||||
def profile_hash
|
||||
@@profile_hashes ||= {}
|
||||
@@profile_hashes[@profile] ||= hash_of_files "#{PROFILES_PATH}/#{@profile}.lua"
|
||||
profile_hashes ||= {}
|
||||
profile_hashes[@profile] ||= hash_of_files "#{PROFILES_PATH}/#{@profile}.lua"
|
||||
end
|
||||
|
||||
def osm_hash
|
||||
@ -29,15 +32,15 @@ def lua_lib_hash
|
||||
end
|
||||
|
||||
def bin_extract_hash
|
||||
@@bin_extract_hash ||= hash_of_files "#{BIN_PATH}/osrm-extract"
|
||||
bin_extract_hash ||= hash_of_files "#{BIN_PATH}/osrm-extract"
|
||||
end
|
||||
|
||||
def bin_prepare_hash
|
||||
@@bin_prepare_hash ||= hash_of_files "#{BIN_PATH}/osrm-prepare"
|
||||
bin_prepare_hash ||= hash_of_files "#{BIN_PATH}/osrm-prepare"
|
||||
end
|
||||
|
||||
def bin_routed_hash
|
||||
@@bin_routed_hash ||= hash_of_files "#{BIN_PATH}/osrm-routed"
|
||||
bin_routed_hash ||= hash_of_files "#{BIN_PATH}/osrm-routed"
|
||||
end
|
||||
|
||||
#combine state of data, profile and binaries into a hash that identifies the exact test scenario
|
||||
|
@ -1,23 +1,25 @@
|
||||
require 'OSM/StreamParser'
|
||||
|
||||
locations = nil
|
||||
|
||||
class OSMTestParserCallbacks < OSM::Callbacks
|
||||
@@locations = nil
|
||||
locations = nil
|
||||
|
||||
def self.locations
|
||||
if @@locations
|
||||
@@locations
|
||||
if locations
|
||||
locations
|
||||
else
|
||||
#parse the test file, so we can later reference nodes and ways by name in tests
|
||||
@@locations = {}
|
||||
locations = {}
|
||||
file = 'test/data/test.osm'
|
||||
callbacks = OSMTestParserCallbacks.new
|
||||
parser = OSM::StreamParser.new(:filename => file, :callbacks => callbacks)
|
||||
parser.parse
|
||||
puts @@locations
|
||||
puts locations
|
||||
end
|
||||
end
|
||||
|
||||
def node(node)
|
||||
@@locations[node.name] = [node.lat,node.lon]
|
||||
locations[node.name] = [node.lat,node.lon]
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user