diff options
author | Eric Wong <normalperson@yhbt.net> | 2015-01-22 04:08:34 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2015-01-22 04:08:34 +0000 |
commit | 9738138e9266b1c8f955bc92eabd27313a0e853f (patch) | |
tree | 9311e8b3d087c34a5883199b83ce636576e65309 /test/setup.rb | |
parent | ea6ea79399288737ced11fe60a47a5161fc447ed (diff) | |
download | mogilefs-client-9738138e9266b1c8f955bc92eabd27313a0e853f.tar.gz |
This should prevent stray processes from being leftover after tests are run as well as cleaning up tmpdirs more thoroughly.
Diffstat (limited to 'test/setup.rb')
-rw-r--r-- | test/setup.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/test/setup.rb b/test/setup.rb index 8fda7f1..3c64c2b 100644 --- a/test/setup.rb +++ b/test/setup.rb @@ -58,13 +58,8 @@ require 'socket' class TempServer attr_reader :port, :pid - def self.destroy_all! - ObjectSpace.each_object(TempServer) { |t| t.destroy! } - end - - at_exit { TempServer.destroy_all! } - def initialize(server_proc, port = nil) + @destroy_pid = $$ @pid = @sock = nil @port = port retries = 10 @@ -85,6 +80,7 @@ class TempServer end def destroy! + return if @destroy_pid != $$ @sock.close rescue nil Process.kill('KILL', @pid) rescue nil end |