Skip to content

Instantly share code, notes, and snippets.

@konk303
Last active July 6, 2017 01:31
Show Gist options
  • Save konk303/0f32019c7fc0d1119b5936888ecb9884 to your computer and use it in GitHub Desktop.
Save konk303/0f32019c7fc0d1119b5936888ecb9884 to your computer and use it in GitHub Desktop.
Simplified test-queue runner with simplecov
#!/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
@konk303
Copy link
Author

konk303 commented Apr 1, 2016

for some reason I had to define SimpleCov.at_exit outside of SimpleCov.start {} to make it defined as I wanted.

(I guess it's simplecov's matter, nothing to do with tmm1/test-queue#35 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment