Sha256: 7a816e833ce5539e0d6978a0a312dfd64747bf631883a01194fd74c25123a47c
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'drb/drb' require 'rbconfig' # This is based off of spec_server.rb from rspec-rails (David Chelimsky), which was based on Florian Weber's TDDMate class Spork::SpecServer DRB_PORT = 8989 def self.restart_test_server puts "restarting" config = ::Config::CONFIG ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT'] command_line = [ruby, $0, ARGV].flatten.join(' ') exec(command_line) end def self.daemonize(pid_file = nil) return yield if $DEBUG pid = Process.fork{ Process.setsid trap("SIGINT"){ exit! 0 } trap("SIGTERM"){ exit! 0 } trap("SIGHUP"){ restart_test_server } File.open("/dev/null"){|f| STDERR.reopen f STDIN.reopen f STDOUT.reopen f } run } puts "spec_server launched (PID: %d)" % pid File.open(pid_file,"w"){|f| f.puts pid } if pid_file exit! 0 end def self.run trap("USR2") { ::Spork::SpecServer.restart_test_server } if Signal.list.has_key?("USR2") DRb.start_service("druby://127.0.0.1:#{DRB_PORT}", ::Spork::SpecServer.new) puts "Spork is ready and listening on #{DRB_PORT}!" DRb.thread.join end def run(argv, stderr, stdout) $stdout = stdout $stderr = stderr child_pid = Kernel.fork do Spork.running! load ::Spork::SPEC_HELPER_FILE ::Spec::Runner::CommandLine.run( ::Spec::Runner::OptionParser.parse( argv, $stderr, $stdout ) ) end Process.wait(child_pid) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
timcharper-spork-0.3.1 | lib/spork/spec_server.rb |
timcharper-spork-0.3 | lib/spork/spec_server.rb |