Permalink
Browse files

cucumber cleanup, removed unused code

  • Loading branch information...
emiltin committed Dec 16, 2012
1 parent 7e9614b commit ec56478a3c5d7b6ee7fec9e1b35d64e5bc2325c9
Showing with 187 additions and 349 deletions.
  1. +1 −1 features/bicycle/access.feature
  2. +1 −1 features/bicycle/area.feature
  3. +1 −1 features/bicycle/barrier.feature
  4. +1 −1 features/bicycle/cycleway.feature
  5. +1 −1 features/bicycle/destination.feature
  6. +1 −1 features/bicycle/ferry.feature
  7. +1 −1 features/bicycle/maxspeed.feature
  8. +1 −1 features/bicycle/names.feature
  9. +1 −1 features/bicycle/oneway.feature
  10. +1 −1 features/bicycle/restrictions.feature
  11. +1 −1 features/bicycle/stop_area.feature
  12. +1 −1 features/bicycle/train.feature
  13. +2 −2 features/bicycle/way.feature
  14. +1 −1 features/car/access.feature
  15. +1 −1 features/car/barrier.feature
  16. +1 −1 features/car/destination.feature
  17. +1 −1 features/car/ferry.feature
  18. +1 −1 features/car/maxspeed.feature
  19. +1 −1 features/car/names.feature
  20. +1 −1 features/car/oneway.feature
  21. +1 −1 features/car/restrictions.feature
  22. +1 −1 features/car/way.feature
  23. +1 −1 features/foot/oneway.feature
  24. +1 −1 features/foot/way.feature
  25. +1 −1 features/investigate/weird.feature
  26. +2 −2 features/step_definitions/data.rb
  27. +0 −14 features/step_definitions/errors.rb
  28. +0 −74 features/step_definitions/processing.rb
  29. +22 −0 features/step_definitions/requests.rb
  30. +40 −0 features/step_definitions/routability.rb
  31. +0 −176 features/step_definitions/routing.rb
  32. +28 −4 features/stress/launch.feature
  33. +7 −7 features/support/config.rb
  34. +3 −8 features/support/data.rb
  35. +4 −4 features/support/hash.rb
  36. +2 −2 features/support/log.rb
  37. +23 −0 features/support/osm_parser.rb
  38. +0 −17 features/support/request.rb
  39. +17 −0 features/support/route.rb
  40. +1 −1 features/testbot/bad.feature
  41. +1 −1 features/testbot/basic.feature
  42. +1 −1 features/testbot/bearing.feature
  43. +1 −1 features/testbot/distance.feature
  44. +1 −1 features/testbot/ferry.feature
  45. +1 −1 features/testbot/origin.feature
  46. +1 −1 features/testbot/penalty.feature
  47. +2 −4 features/testbot/snap.feature
  48. +1 −1 features/testbot/time.feature
  49. +1 −1 features/testbot/turns.feature
  50. +1 −1 features/testbot/utf.feature
  51. +1 −1 features/testbot/weight.feature
@@ -3,7 +3,7 @@ Feature: Bike - Restricted access
Reference: http://wiki.openstreetmap.org/wiki/Key:access
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Access tag hierachy on ways
Then routability should be
@@ -2,7 +2,7 @@
Feature: Bike - Squares and other areas
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
@square
Scenario: Bike - Route along edge of a squares
@@ -2,7 +2,7 @@
Feature: Barriers
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Barriers
Then routability should be
@@ -3,7 +3,7 @@ Feature: Bike - Cycle tracks/lanes
Reference: http://wiki.openstreetmap.org/wiki/Key:cycleway
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Cycle tracks/lanes should enable biking
Then routability should be
@@ -2,7 +2,7 @@
Feature: Bike - Destination only, no passing through
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Destination only street
Given the node map
@@ -2,7 +2,7 @@
Feature: Bike - Handle ferry routes
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Ferry route
Given the node map
@@ -2,7 +2,7 @@
Feature: Bike - Max speed restrictions
Background: Use specific speeds
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Respect maxspeeds when lower that way type speed
Given the node map
@@ -2,7 +2,7 @@
Feature: Bike - Street names in instructions
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - A named street
Given the node map
@@ -3,7 +3,7 @@ Feature: Bike - Oneway streets
Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Simple oneway
Then routability should be
@@ -4,7 +4,7 @@ Feature: Bike - Turn restrictions
Note that if u-turns are allowed, turn restrictions can lead to suprising, but correct, routes.
Background: Use car routing
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
@no_turning
Scenario: Bike - No left turn
@@ -4,7 +4,7 @@ Platforms and railway/bus lines are connected using a relation rather that a way
http://wiki.openstreetmap.org/wiki/Tag:public_transport%3Dstop_area
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Platforms tagged using public_transport
Then routability should be
@@ -3,7 +3,7 @@ Feature: Bike - Handle ferry routes
Bringing bikes on trains and subways
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Bringing bikes on trains
Then routability should be
@@ -2,11 +2,11 @@
Feature: Bike - Accessability of different way types
Background:
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Scenario: Bike - Basic access
Bikes are allowed on footways etc because you can pull your bike at a lower speed.
- Given the speedprofile "bicycle"
+ Given the profile "bicycle"
Then routability should be
| highway | forw |
| (nil) | |
@@ -3,7 +3,7 @@ Feature: Car - Restricted access
Reference: http://wiki.openstreetmap.org/wiki/Key:access
Background:
- Given the speedprofile "car"
+ Given the profile "car"
Scenario: Car - Access tag hierachy on ways
Then routability should be
@@ -2,7 +2,7 @@
Feature: Car - Barriers
Background:
- Given the speedprofile "car"
+ Given the profile "car"
Scenario: Car - Barriers
Then routability should be
@@ -2,7 +2,7 @@
Feature: Car - Destination only, no passing through
Background:
- Given the speedprofile "car"
+ Given the profile "car"
Scenario: Car - Destination only street
Given the node map
@@ -2,7 +2,7 @@
Feature: Car - Handle ferry routes
Background:
- Given the speedprofile "car"
+ Given the profile "car"
Scenario: Car - Use a ferry route
Given the node map
@@ -2,7 +2,7 @@
Feature: Car - Max speed restrictions
Background: Use specific speeds
- Given the speedprofile "car"
+ Given the profile "car"
Given a grid size of 1000 meters
Scenario: Car - Respect maxspeeds when lower that way type speed
@@ -2,7 +2,7 @@
Feature: Car - Street names in instructions
Background:
- Given the speedprofile "car"
+ Given the profile "car"
Scenario: Car - A named street
Given the node map
@@ -3,7 +3,7 @@ Feature: Car - Oneway streets
Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing
Background:
- Given the speedprofile "car"
+ Given the profile "car"
Scenario: Car - Simple oneway
Then routability should be
@@ -4,7 +4,7 @@ Feature: Car - Turn restrictions
Note that if u-turns are allowed, turn restrictions can lead to suprising, but correct, routes.
Background: Use car routing
- Given the speedprofile "car"
+ Given the profile "car"
@no_turning
Scenario: Car - No left turn
View
@@ -2,7 +2,7 @@
Feature: Car - Accessability of different way types
Background:
- Given the speedprofile "car"
+ Given the profile "car"
Scenario: Car - Basic access
Then routability should be
@@ -3,7 +3,7 @@ Feature: Foot - Oneway streets
Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing
Background:
- Given the speedprofile "foot"
+ Given the profile "foot"
Scenario: Foot - Walking should not be affected by oneways
Then routability should be
@@ -2,7 +2,7 @@
Feature: Foot - Accessability of different way types
Background:
- Given the speedprofile "foot"
+ Given the profile "foot"
Scenario: Foot - Basic access
Then routability should be
@@ -2,7 +2,7 @@
Feature: Weird routings discovered
Background:
- Given the speedprofile "testbot"
+ Given the profile "testbot"
Scenario: Routing on a oneway roundabout
Given the node map
@@ -1,5 +1,5 @@
-Given /^the speedprofile "([^"]*)"$/ do |profile|
- read_speedprofile profile
+Given /^the profile "([^"]*)"$/ do |profile|
+ set_profile profile
end
Given /^a grid size of (\d+) meters$/ do |meters|
@@ -1,14 +0,0 @@
-
-When /^I preprocess data$/ do
- begin
- reprocess
- rescue OSRMError => e
- @process_error = e
- end
-end
-
-Then /^preparing should return code (\d+)$/ do |code|
- @process_error.class.should == OSRMError
- @process_error.process.should == 'osrm-prepare'
- @process_error.code.to_i.should == code.to_i
-end
@@ -1,74 +0,0 @@
-require 'OSM/StreamParser'
-
-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
- @@locations = {}
- file = 'test/data/test.osm'
- callbacks = OSMTestParserCallbacks.new
- parser = OSM::StreamParser.new(:filename => file, :callbacks => callbacks)
- parser.parse
- puts @@locations
- end
- end
-
- def node(node)
- @@locations[node.name] = [node.lat,node.lon]
- end
-end
-
-
-Given /^the OSM file contains$/ do |string|
- file = 'data/test.osm'
- File.open( file, 'w') {|f| f.write(string) }
-
- #convert from .osm to .osm.pbf, which is the format osrm reads
- system "osmosis --read-xml data/test.osm --write-pbf data/test.osm.pbf omitmetadata=true"
-end
-
-Given /^the speedprofile contains$/ do |string|
- File.open( 'speedprofile.ini', 'w') {|f| f.write(string) }
-end
-
-
-
-Given /^the data file "([^"]*)" is present$/ do |file|
- File.exists?(file).should == true
-end
-
-When /^I run the extractor with "([^"]*)"$/ do |cmd|
- @response = `#{cmd}`
- #Dir.chdir @test_folder do
- # @response = IO.popen([cmd, :err=>[:child, :out]]) { |ls_io| ls_result_with_error = ls_io.read }
- #end
-end
-
-When /^I run the preprocessor with "([^"]*)"$/ do |cmd|
- @response = `#{cmd}`
-end
-
-Given /^the preprocessed files for "([^"]*)" are present and up to date$/ do |area|
- File.exists?("#{area}.osrm").should == true
- File.exists?("#{area}.osrm.names").should == true
- File.exists?("#{area}.osrm.restrictions").should == true
- File.exists?("#{area}.osrm.hsgr").should == true
- File.exists?("#{area}.osrm.nodes").should == true
- File.exists?("#{area}.osrm.edges").should == true
- File.exists?("#{area}.osrm.ramIndex").should == true
- File.exists?("#{area}.osrm.fileIndex").should == true
- File.exists?("#{area}.osrm.tiemstamp").should == true
-end
-
-Then /^I should see the file "([^"]*)"$/ do |file|
- File.exists?(file).should == true
-end
-
-When /^preprocessed files for "([^"]*)" has been removed$/ do |file|
- FileUtils.rm_r Dir["#{file}.*"], :secure => true
-end
-
@@ -21,3 +21,25 @@
@json['transactionId'].class.should == String
end
+Then /^response should be a well-formed route$/ do
+ step "response should be well-formed"
+ @json['status_message'].class.should == String
+ @json['route_summary'].class.should == Hash
+ @json['route_geometry'].class.should == String
+ @json['route_instructions'].class.should == Array
+ @json['via_points'].class.should == Array
+end
+
+When /^I preprocess data$/ do
+ begin
+ reprocess
+ rescue OSRMError => e
+ @process_error = e
+ end
+end
+
+Then /^preparing should return code (\d+)$/ do |code|
+ @process_error.class.should == OSRMError
+ @process_error.process.should == 'osrm-prepare'
+ @process_error.code.to_i.should == code.to_i
+end
@@ -0,0 +1,40 @@
+Then /^routability should be$/ do |table|
+ build_ways_from_table table
+ reprocess
+ actual = []
+ if table.headers&["forw","backw","bothw"] == []
+ raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
+ end
+ OSRMLauncher.new do
+ table.hashes.each_with_index do |row,i|
+ got = row.dup
+ attempts = []
+ ['forw','backw','bothw'].each do |direction|
+ if table.headers.include? direction
+ if direction == 'forw' || direction == 'bothw'
+ response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}")
+ elsif direction == 'backw' || direction == 'bothw'
+ response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}")
+ end
+ got[direction] = route_status response
+ json = JSON.parse(response.body)
+ if got[direction].empty? == false
+ route = way_list json['route_instructions']
+ if route != "w#{i}"
+ got[direction] = "testing w#{i}, but got #{route}!?"
+ elsif row[direction] =~ /\d+s/
+ time = json['route_summary']['total_time']
+ got[direction] = "#{time}s"
+ end
+ end
+ if got[direction] != row[direction]
+ attempts << { :attempt => direction, :query => @query, :response => response }
+ end
+ end
+ end
+ log_fail row,got,attempts if got != row
+ actual << got
+ end
+ end
+ table.routing_diff! actual
+end
Oops, something went wrong.

0 comments on commit ec56478

Please sign in to comment.