use ruby 1.9 and Process.spawn when running test
This commit is contained in:
		
							parent
							
								
									2231765c9e
								
							
						
					
					
						commit
						a51c7416d5
					
				| @ -2,6 +2,12 @@ require 'rspec/expectations' | |||||||
| 
 | 
 | ||||||
| DEFAULT_PORT = 5000 | DEFAULT_PORT = 5000 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | puts "Ruby version #{RUBY_VERSION}" | ||||||
|  | unless RUBY_VERSION =~ /^1.9/ | ||||||
|  |   raise "*** Please upgrade to Ruby 1.9.x to run the OSRM cucumber tests" | ||||||
|  | end | ||||||
|  | 
 | ||||||
| if ENV["OSRM_PORT"] | if ENV["OSRM_PORT"] | ||||||
|   OSRM_PORT = ENV["OSRM_PORT"].to_i |   OSRM_PORT = ENV["OSRM_PORT"].to_i | ||||||
|   puts "Port set to #{OSRM_PORT}" |   puts "Port set to #{OSRM_PORT}" | ||||||
| @ -9,3 +15,4 @@ else | |||||||
|   OSRM_PORT = DEFAULT_PORT |   OSRM_PORT = DEFAULT_PORT | ||||||
|   puts "Using default port #{OSRM_PORT}" |   puts "Using default port #{OSRM_PORT}" | ||||||
| end | end | ||||||
|  | 
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| require 'socket' | require 'socket' | ||||||
| require 'sys/proctable' | require 'open3' | ||||||
| 
 | 
 | ||||||
| LAUNCH_TIMEOUT = 2 | LAUNCH_TIMEOUT = 2 | ||||||
| SHUTDOWN_TIMEOUT = 2 | SHUTDOWN_TIMEOUT = 2 | ||||||
| @ -38,9 +38,9 @@ class OSRMLauncher | |||||||
|    |    | ||||||
|    |    | ||||||
|   def osrm_up? |   def osrm_up? | ||||||
|     if @pipe |     if @pid | ||||||
|       begin |       begin | ||||||
|         Process.getpgid @pipe.pid |         Process.getpgid @pid | ||||||
|         true |         true | ||||||
|       rescue Errno::ESRCH |       rescue Errno::ESRCH | ||||||
|         false |         false | ||||||
| @ -52,22 +52,19 @@ class OSRMLauncher | |||||||
| 
 | 
 | ||||||
|   def osrm_up |   def osrm_up | ||||||
|     return if osrm_up? |     return if osrm_up? | ||||||
|     #exec avoids popen running osrm-routed inside a shell |     @pid = Process.spawn(['../osrm-routed',''],:out=>'osrm-routed.log', :err=>'osrm-routed.log') | ||||||
|     #if the cmd is run inside a shell, popen returns the pid for the shell, and if we try to kill it, |  | ||||||
|     #the child process is orphaned, and we can't terminate it. |  | ||||||
|     @pipe = IO.popen('exec ../osrm-routed 1>>osrm-routed.log 2>>osrm-routed.log') |  | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def osrm_down |   def osrm_down | ||||||
|     if @pipe |     if @pid | ||||||
|       Process.kill 'TERM', @pipe.pid |       Process.kill 'TERM', @pid | ||||||
|       wait_for_shutdown |       wait_for_shutdown | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def kill |   def kill | ||||||
|     if @pipe |     if @pid | ||||||
|       Process.kill 'KILL', @pipe.pid |       Process.kill 'KILL', @pid | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user