Skip to content

Instantly share code, notes, and snippets.

@carlosantoniodasilva
Created June 27, 2013 15:39
Show Gist options
  • Save carlosantoniodasilva/5877525 to your computer and use it in GitHub Desktop.
Save carlosantoniodasilva/5877525 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'socket'
test_file = ARGV[0]
socket = UNIXSocket.new('testing.sock')
socket.write(test_file)
socket.close_write
while r = socket.read(1)
print r
end
# puts socket.read
#!/usr/bin/env ruby
ENV['RAILS_ENV'] = 'test'
require 'benchmark'
require 'socket'
rails_boot = Benchmark.measure { require './config/application' }
puts "Rails load: #{rails_boot}"
server = UNIXServer.new('testing.sock')
parent_process_id = Process.pid
at_exit {
if Process.pid == parent_process_id
File.unlink('testing.sock')
end
}
trap('INT') { exit }
loop do
client = server.accept
test_file = client.read
pid = fork do
$stdout.reopen(client)
$LOAD_PATH.unshift('./spec')
require './' + test_file
end
Process.wait(pid)
client.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment