lib/spork/server.rb in spork-0.4.2 vs lib/spork/server.rb in spork-0.4.4
- old
+ new
@@ -1,7 +1,8 @@
require 'drb/drb'
require 'rbconfig'
+require 'spork/forker.rb'
# This is based off of spec_server.rb from rspec-rails (David Chelimsky), which was based on Florian Weber's TDDMate
class Spork::Server
@@supported_servers = []
@@ -91,23 +92,20 @@
self.class.helper_file
end
def run(argv, stderr, stdout)
return false if running?
- $stdout = stdout
- $stderr = stderr
- @child_pid = Kernel.fork do
+ @child = ::Spork::Forker.new do
+ $stdout, $stderr = stdout, stderr
Spork.exec_each_run(helper_file)
run_tests(argv, stderr, stdout)
end
- Process.wait(@child_pid)
- @child_pid = nil
- true
+ @child.result
end
def running?
- !! @child_pid
+ @child && @child.running?
end
private
def self.preload
if bootstrapped?
@@ -138,19 +136,16 @@
command_line = [ruby, $0, ARGV].flatten.join(' ')
exec(command_line)
end
def abort
- if running?
- Process.kill(Signal.list['TERM'], @child_pid)
- true
- end
+ @child && @child.abort
end
def sig_int_received
if running?
abort
- puts "Running specs stopped. Press CTRL-C again to stop the server."
+ puts "Running tests stopped. Press CTRL-C again to stop the server."
else
exit!(0)
end
end
end
\ No newline at end of file