update cucumber test to work with lua profiles

This commit is contained in:
Emil Tin
2012-09-19 18:35:45 +02:00
parent 75cd287ab0
commit 74cc50f52b
15 changed files with 596 additions and 107 deletions
+3 -12
View File
@@ -3,25 +3,16 @@ def speedprofile
end
def reset_speedprofile
@speedprofile = {}
@speedprofile = nil
read_speedprofile DEFAULT_SPEEDPROFILE
end
def read_speedprofile profile
@speedprofile = {}
@speedprofile_str = nil
s = File.read "test/speedprofiles/#{profile}.ini"
s.scan /(.*)=(.*)/ do |option|
@speedprofile[option[0].strip] = option[1].strip
end
end
def speedprofile_str
@speedprofile_str ||= "[Scenario: #{@scenario_title}]\n" + @speedprofile.map { |k,v| " #{k} = #{v}" }.join("\n")
@speedprofile = profile
end
def write_speedprofile
File.open( 'speedprofile.ini', 'w') {|f| f.write( speedprofile_str ) }
FileUtils.copy_file "profiles/#{@speedprofile}.lua", "profile.lua"
end
def write_server_ini
+1 -1
View File
@@ -14,7 +14,7 @@ DEFAULT_SPEEDPROFILE = 'bicycle'
WAY_SPACING = 100
DEFAULT_GRID_SIZE = 100 #meters
ORIGIN = [1,1]
ORIGIN = [12,55]
def set_grid_size meters
@zoom = 0.001*(meters.to_f/111.21)
+1 -5
View File
@@ -12,11 +12,7 @@ def hash_of_file path
end
def speedprofile_hash
@speedprofile_hash ||= Digest::SHA1.hexdigest speedprofile_str
end
def osm_hash
@osm_hash ||= Digest::SHA1.hexdigest osm_str
@speedprofile_hash ||= hash_of_file "profile.lua"
end
def osm_hash
+5 -4
View File
@@ -13,12 +13,13 @@ def log_scenario_fail_info
log "========================================="
log "Failed scenario: #{@scenario_title}"
log "Time: #{@scenario_time}"
log "Fingerprint: #{@fingerprint}"
log "Profile: #{@speedprofile}"
log
log '```xml' #so output can be posted directly to github comment fields
log osm_str.strip
log '```'
log
log speedprofile_str
log
@has_logged_scenario_info = true
end
@@ -27,7 +28,7 @@ def log_fail expected,actual,failed
log_scenario_fail_info
log "== "
log "Expected: #{expected}"
log "Got: #{actual}"
log "Got: #{actual}"
log
failed.each do |fail|
log "Attempt: #{fail[:attempt]}"
@@ -49,8 +50,8 @@ def log_preprocess_info
log osm_str, :preprocess
log '```', :preprocess
log '', :preprocess
log "== Speed profile:", :preprocess
log speedprofile_str.strip, :preprocess
log "== Profile:", :preprocess
log @speedprofile, :preprocess
log '', :preprocess
@has_logged_preprocess_info = true
end