removing trailing whitespace in cuke/ruby files
This commit is contained in:
parent
b5bfdb56dc
commit
407d73a735
@ -7,6 +7,7 @@ Feature: Bike - Accessability of different way types
|
||||
Scenario: Bike - Routability of way types
|
||||
Bikes are allowed on footways etc because you can pull your bike at a lower speed.
|
||||
Pier is not allowed, since it's tagged using man_made=pier.
|
||||
|
||||
Then routability should be
|
||||
| highway | bothw |
|
||||
| (nil) | |
|
||||
|
@ -35,9 +35,9 @@ Given /^the node locations$/ do |table|
|
||||
name = row['node']
|
||||
raise "*** duplicate node '#{name}'" if find_node_by_name name
|
||||
if name.match /[a-z]/
|
||||
add_osm_node name, row['lon'].to_f, row['lat'].to_f
|
||||
add_osm_node name, row['lon'].to_f, row['lat'].to_f
|
||||
else
|
||||
add_location name, row['lon'].to_f, row['lat'].to_f
|
||||
add_location name, row['lon'].to_f, row['lat'].to_f
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -55,7 +55,7 @@ Given /^the ways$/ do |table|
|
||||
table.hashes.each do |row|
|
||||
way = OSM::Way.new make_osm_id, OSM_USER, OSM_TIMESTAMP
|
||||
way.uid = OSM_UID
|
||||
|
||||
|
||||
nodes = row.delete 'nodes'
|
||||
raise "*** duplicate way '#{nodes}'" if name_way_hash[nodes]
|
||||
nodes.each_char do |c|
|
||||
@ -64,14 +64,14 @@ Given /^the ways$/ do |table|
|
||||
raise "*** unknown node '#{c}'" unless node
|
||||
way << node
|
||||
end
|
||||
|
||||
|
||||
defaults = { 'highway' => 'primary' }
|
||||
tags = defaults.merge(row)
|
||||
|
||||
if row['highway'] == '(nil)'
|
||||
tags.delete 'highway'
|
||||
end
|
||||
|
||||
|
||||
if row['name'] == nil
|
||||
tags['name'] = nodes
|
||||
elsif (row['name'] == '""') || (row['name'] == "''")
|
||||
@ -81,7 +81,7 @@ Given /^the ways$/ do |table|
|
||||
else
|
||||
tags['name'] = row['name']
|
||||
end
|
||||
|
||||
|
||||
way << tags
|
||||
osm_db << way
|
||||
name_way_hash[nodes] = way
|
||||
|
@ -16,9 +16,9 @@ When /^I request nearest I should get$/ do |table|
|
||||
coord = json['mapped_coordinate']
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
got = {'in' => row['in'], 'out' => coord }
|
||||
|
||||
|
||||
ok = true
|
||||
row.keys.each do |key|
|
||||
if key=='out'
|
||||
@ -30,12 +30,12 @@ When /^I request nearest I should get$/ do |table|
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
unless ok
|
||||
failed = { :attempt => 'nearest', :query => @query, :response => response }
|
||||
log_fail row,got,[failed]
|
||||
end
|
||||
|
||||
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
|
@ -8,11 +8,11 @@ When /^I route I should get$/ do |table|
|
||||
node = find_node_by_name(row['from'])
|
||||
raise "*** unknown from-node '#{row['from']}" unless node
|
||||
waypoints << node
|
||||
|
||||
|
||||
node = find_node_by_name(row['to'])
|
||||
raise "*** unknown to-node '#{row['to']}" unless node
|
||||
waypoints << node
|
||||
|
||||
|
||||
got = {'from' => row['from'], 'to' => row['to'] }
|
||||
elsif row['waypoints']
|
||||
row['waypoints'].split(',').each do |n|
|
||||
@ -24,7 +24,7 @@ When /^I route I should get$/ do |table|
|
||||
else
|
||||
raise "*** no waypoints"
|
||||
end
|
||||
|
||||
|
||||
params = {}
|
||||
row.each_pair do |k,v|
|
||||
if k =~ /param:(.*)/
|
||||
@ -36,7 +36,7 @@ When /^I route I should get$/ do |table|
|
||||
got[k]=v
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
response = request_route(waypoints, params)
|
||||
if response.code == "200" && response.body.empty? == false
|
||||
json = JSON.parse response.body
|
||||
@ -48,7 +48,7 @@ When /^I route I should get$/ do |table|
|
||||
modes = mode_list json['route_instructions']
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if table.headers.include? 'start'
|
||||
got['start'] = instructions ? json['route_summary']['start_point'] : nil
|
||||
end
|
||||
@ -83,7 +83,7 @@ When /^I route I should get$/ do |table|
|
||||
got['#'] = row['#'] # copy value so it always match
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ok = true
|
||||
row.keys.each do |key|
|
||||
if FuzzyMatch.match got[key], row[key]
|
||||
@ -92,12 +92,12 @@ When /^I route I should get$/ do |table|
|
||||
ok = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
unless ok
|
||||
failed = { :attempt => 'route', :query => @query, :response => response }
|
||||
log_fail row,got,[failed]
|
||||
end
|
||||
|
||||
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
|
@ -23,7 +23,7 @@ class Cucumber::Ast::Table
|
||||
require_diff_lcs
|
||||
cell_matrix.extend(Diff::LCS)
|
||||
changes = cell_matrix.diff(other_table_cell_matrix).flatten
|
||||
|
||||
|
||||
inserted = 0
|
||||
missing = 0
|
||||
|
||||
@ -43,7 +43,7 @@ class Cucumber::Ast::Table
|
||||
#change index so we interleave instead
|
||||
insert_row_pos = change.position + inserted + 1
|
||||
#insert_row_pos = change.position + missing #original
|
||||
|
||||
|
||||
inserted_row = change.element
|
||||
inserted_row.each{|cell| cell.status = :comment}
|
||||
cell_matrix.insert(insert_row_pos, inserted_row)
|
||||
@ -66,7 +66,7 @@ class Cucumber::Ast::Table
|
||||
end
|
||||
|
||||
clear_cache!
|
||||
should_raise =
|
||||
should_raise =
|
||||
missing_row_pos && options[:missing_row] ||
|
||||
insert_row_pos && options[:surplus_row] ||
|
||||
missing_col && options[:missing_col] ||
|
||||
|
@ -20,7 +20,7 @@ ORIGIN = [1,1]
|
||||
|
||||
class Location
|
||||
attr_accessor :lon,:lat
|
||||
|
||||
|
||||
def initialize lon,lat
|
||||
@lat = lat
|
||||
@lon = lon
|
||||
@ -44,16 +44,16 @@ def build_ways_from_table table
|
||||
#NOTE:
|
||||
#currently osrm crashes when processing an isolated oneway with just 2 nodes, so we use 4 edges
|
||||
#this is relatated to the fact that a oneway dead-end street doesn't make a lot of sense
|
||||
|
||||
|
||||
#if we stack ways on different x coordinates, routability tests get messed up, because osrm might pick a neighboring way if the one test can't be used.
|
||||
#instead we place all lines as a string on the same y coordinate. this prevents using neightboring ways.
|
||||
|
||||
|
||||
#a few nodes...
|
||||
node1 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(0+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node2 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(1+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node3 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(2+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node4 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(3+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node5 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(4+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node1 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(0+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node2 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(1+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node3 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(2+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node4 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(3+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node5 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(4+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node1.uid = OSM_UID
|
||||
node2.uid = OSM_UID
|
||||
node3.uid = OSM_UID
|
||||
@ -70,7 +70,7 @@ def build_ways_from_table table
|
||||
osm_db << node3
|
||||
osm_db << node4
|
||||
osm_db << node5
|
||||
|
||||
|
||||
#...with a way between them
|
||||
way = OSM::Way.new make_osm_id, OSM_USER, OSM_TIMESTAMP
|
||||
way.uid = OSM_UID
|
||||
@ -79,22 +79,22 @@ def build_ways_from_table table
|
||||
way << node3
|
||||
way << node4
|
||||
way << node5
|
||||
|
||||
|
||||
tags = row.dup
|
||||
|
||||
|
||||
# remove tags that describe expected test result
|
||||
tags.reject! do |k,v|
|
||||
k =~ /^forw\b/ ||
|
||||
k =~ /^forw\b/ ||
|
||||
k =~ /^backw\b/ ||
|
||||
k =~ /^bothw\b/
|
||||
end
|
||||
|
||||
|
||||
##remove empty tags
|
||||
tags.reject! { |k,v| v=='' }
|
||||
|
||||
|
||||
# sort tag keys in the form of 'node/....'
|
||||
way_tags = { 'highway' => 'primary' }
|
||||
|
||||
|
||||
node_tags = {}
|
||||
tags.each_pair do |k,v|
|
||||
if k =~ /node\/(.*)/
|
||||
@ -111,11 +111,11 @@ def build_ways_from_table table
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
way_tags['name'] = "w#{ri}"
|
||||
way << way_tags
|
||||
node3 << node_tags
|
||||
|
||||
|
||||
osm_db << way
|
||||
end
|
||||
end
|
||||
@ -207,7 +207,7 @@ def osm_str
|
||||
@osm_str
|
||||
end
|
||||
|
||||
def write_osm
|
||||
def write_osm
|
||||
#write .oms file if needed
|
||||
Dir.mkdir DATA_FOLDER unless File.exist? DATA_FOLDER
|
||||
@osm_file = "#{DATA_FOLDER}/#{sanitized_scenario_title}_#{fingerprint}"
|
||||
@ -262,7 +262,7 @@ def reprocess
|
||||
unless system "#{BIN_PATH}/osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} #{PROFILES_PATH}/#{@profile}.lua"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
||||
end
|
||||
end
|
||||
log '', :preprocess
|
||||
end
|
||||
log_preprocess_done
|
||||
|
@ -10,13 +10,13 @@ class OSRMError < StandardError
|
||||
@log = log
|
||||
@extract = log_tail @log, @lines
|
||||
end
|
||||
|
||||
|
||||
def to_s
|
||||
"*** #{@msg}\nLast #{@lines} lines from #{@log}:\n#{@extract}\n"
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def log_tail path, n
|
||||
File.open(path) do |f|
|
||||
return f.tail(n).map { |line| " > #{line}" }.join "\n"
|
||||
|
@ -22,13 +22,13 @@ class FuzzyMatch
|
||||
return got =~ /#{$1}/
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.match_location got, want
|
||||
match( got[0], "#{want.lat} ~0.0025%" ) &&
|
||||
match( got[1], "#{want.lon} ~0.0025%" )
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
@ -18,7 +18,7 @@ class OSRMLauncher
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def launch
|
||||
Timeout.timeout(LAUNCH_TIMEOUT) do
|
||||
osrm_up
|
||||
@ -27,7 +27,7 @@ class OSRMLauncher
|
||||
rescue Timeout::Error
|
||||
raise RoutedError.new "Launching osrm-routed timed out."
|
||||
end
|
||||
|
||||
|
||||
def shutdown
|
||||
Timeout.timeout(SHUTDOWN_TIMEOUT) do
|
||||
osrm_down
|
||||
@ -36,8 +36,8 @@ class OSRMLauncher
|
||||
kill
|
||||
raise RoutedError.new "Shutting down osrm-routed timed out."
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
def osrm_up?
|
||||
if @pid
|
||||
`ps -o state -p #{@pid}`.split[1].to_s =~ /^[DRST]/
|
||||
|
@ -4,12 +4,12 @@ locations = nil
|
||||
|
||||
class OSMTestParserCallbacks < OSM::Callbacks
|
||||
locations = nil
|
||||
|
||||
|
||||
def self.locations
|
||||
if locations
|
||||
locations
|
||||
else
|
||||
#parse the test file, so we can later reference nodes and ways by name in tests
|
||||
#parse the test file, so we can later reference nodes and ways by name in tests
|
||||
locations = {}
|
||||
file = 'test/data/test.osm'
|
||||
callbacks = OSMTestParserCallbacks.new
|
||||
|
@ -128,7 +128,7 @@ def turn_list instructions
|
||||
r[0].to_s.gsub!(/^\d*/) do |match|
|
||||
types[match.to_i].to_s
|
||||
end
|
||||
end.join(',')
|
||||
end.join(',')
|
||||
end
|
||||
|
||||
def mode_list instructions
|
||||
|
Loading…
Reference in New Issue
Block a user