-
-
Save jjasonclark/6128274 to your computer and use it in GitHub Desktop.
These scripts were the result of the "Faster Rails test runs...with Unix!" screencast at https://www.youtube.com/watch?v=RSehcT4MnRM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'socket' | |
test_file = ARGV[0] | |
socket = UNIXSocket.new('testing.sock') | |
socket.write(test_file) | |
socket.close_write | |
puts socket.read | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
require 'socket' | |
ENV['RAILS_ENV'] = 'test' | |
rails_boot = Benchmark.measure { | |
require './config/application' | |
} | |
puts "Rails loaded after #{rails_boot}s..." | |
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) | |
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