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