patch Ruby files for successful testing on Windows
This commit is contained in:
parent
c4998990e5
commit
d0284991ed
@ -217,7 +217,7 @@ def convert_osm_to_pbf
|
||||
unless File.exist?("#{@osm_file}.osm.pbf")
|
||||
log_preprocess_info
|
||||
log "== Converting #{@osm_file}.osm to protobuffer format...", :preprocess
|
||||
unless system "osmosis --read-xml #{@osm_file}.osm --write-pbf #{@osm_file}.osm.pbf omitmetadata=true 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
|
||||
unless system "osmosis --read-xml #{@osm_file}.osm --write-pbf #{@osm_file}.osm.pbf omitmetadata=true >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||
raise OsmosisError.new $?, "osmosis exited with code #{$?.exitstatus}"
|
||||
end
|
||||
log '', :preprocess
|
||||
@ -253,7 +253,7 @@ 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}"
|
||||
unless system "#{BIN_PATH}/osrm-extract #{@osm_file}.osm#{'.pbf' if pbf?} --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
||||
end
|
||||
@ -265,7 +265,7 @@ 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}"
|
||||
unless system "#{BIN_PATH}/osrm-prepare #{@osm_file}.osrm --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
||||
end
|
||||
|
@ -44,6 +44,13 @@ unless File.exists? TEST_FOLDER
|
||||
raise "*** Test folder #{TEST_FOLDER} doesn't exist."
|
||||
end
|
||||
|
||||
if ENV['OS']=~/Windows.*/ then
|
||||
EXE='.exe'
|
||||
QQ='"'
|
||||
else
|
||||
EXE=''
|
||||
QQ=''
|
||||
end
|
||||
|
||||
AfterConfiguration do |config|
|
||||
clear_log_files
|
||||
|
@ -7,7 +7,7 @@ def hash_of_files paths
|
||||
paths = [paths] unless paths.is_a? Array
|
||||
hash = Digest::SHA1.new
|
||||
for path in paths do
|
||||
open(path,'r') do |io|
|
||||
open(path,'rb') do |io|
|
||||
while !io.eof
|
||||
buf = io.readpartial 1024
|
||||
hash.update buf
|
||||
@ -32,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#{EXE}"
|
||||
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#{EXE}"
|
||||
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#{EXE}"
|
||||
end
|
||||
|
||||
#combine state of data, profile and binaries into a hash that identifies the exact test scenario
|
||||
|
@ -1,6 +1,12 @@
|
||||
require 'socket'
|
||||
require 'open3'
|
||||
|
||||
if ENV['OS']==/Windows.*/ then
|
||||
TERMSIGNAL='TERM'
|
||||
else
|
||||
TERMSIGNAL=9
|
||||
end
|
||||
|
||||
OSRM_ROUTED_LOG_FILE = 'osrm-routed.log'
|
||||
|
||||
class OSRMBackgroundLauncher
|
||||
@ -39,9 +45,15 @@ class OSRMBackgroundLauncher
|
||||
|
||||
def osrm_up?
|
||||
if @pid
|
||||
`ps -o state -p #{@pid}`.split[1].to_s =~ /^[DRST]/
|
||||
else
|
||||
begin
|
||||
if Process.waitpid(@pid, Process::WNOHANG) then
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
rescue Errno::ESRCH, Errno::ECHILD
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -53,7 +65,7 @@ class OSRMBackgroundLauncher
|
||||
|
||||
def osrm_down
|
||||
if @pid
|
||||
Process.kill 'TERM', @pid
|
||||
Process.kill TERMSIGNAL, @pid
|
||||
wait_for_shutdown
|
||||
end
|
||||
end
|
||||
@ -67,7 +79,7 @@ class OSRMBackgroundLauncher
|
||||
def wait_for_connection
|
||||
while true
|
||||
begin
|
||||
socket = TCPSocket.new('localhost', OSRM_PORT)
|
||||
socket = TCPSocket.new('127.0.0.1', OSRM_PORT)
|
||||
return
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep 0.1
|
||||
|
@ -1,6 +1,6 @@
|
||||
require 'net/http'
|
||||
|
||||
HOST = "http://localhost:#{OSRM_PORT}"
|
||||
HOST = "http://127.0.0.1:#{OSRM_PORT}"
|
||||
DESTINATION_REACHED = 15 #OSRM instruction code
|
||||
|
||||
class Hash
|
||||
|
@ -11,7 +11,7 @@ def run_bin bin, options
|
||||
opt.gsub! "{profile}", "#{PROFILES_PATH}/#{@profile}.lua"
|
||||
end
|
||||
|
||||
@stdout = `#{BIN_PATH}/#{bin} #{opt} 2>error.log`
|
||||
@stdout = `#{QQ}#{BIN_PATH}/#{bin}#{EXE}#{QQ} #{opt} 2>error.log`
|
||||
@stderr = File.read 'error.log'
|
||||
@exit_code = $?.exitstatus
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user