Last active
July 6, 2017 01:31
-
-
Save konk303/0f32019c7fc0d1119b5936888ecb9884 to your computer and use it in GitHub Desktop.
Simplified test-queue runner with simplecov
This file contains 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 'test_queue' | |
require 'test_queue/runner/rspec' | |
class MyAppTestRunner < TestQueue::Runner::RSpec | |
def after_fork(num) | |
SimpleCov.command_name "worker#{num}" | |
ActiveRecord::Base.configurations['test']['database'] << num.to_s | |
ActiveRecord::Base.establish_connection(:test) | |
end | |
# initialize | |
def prepare(concurrency) | |
1.upto(concurrency) do |i| | |
ActiveRecord::Tasks::DatabaseTasks.drop_current | |
ActiveRecord::Tasks::DatabaseTasks.create_current | |
ActiveRecord::Tasks::DatabaseTasks.load_schema_current | |
# master doesn't need connection | |
ActiveRecord::Base.connection.disconnect! | |
end | |
end | |
def cleanup_worker | |
# record each worker's result | |
SimpleCov.result | |
end | |
def summarize | |
# output result | |
SimpleCov.at_exit.call | |
end | |
end | |
MyAppTestRunner.new.execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for some reason I had to define
SimpleCov.at_exit
outside ofSimpleCov.start {}
to make it defined as I wanted.(I guess it's simplecov's matter, nothing to do with tmm1/test-queue#35 )