project.store setting not honored in parallel
Hello,
I'm trying to use cover_me 1.0.0.rc6 while running my Rails 3.0.7 app's test suite in parallel with test-loop. Since these parallel tests cannot all write to the same coverage.data file simultaneously, I wanted to assign each of them a unique coverage.data file in my test/test_helper.rb file in the following ways.
Starting CoverMe at the top of my test/test_helper.rb in the master process:
require 'cover_me'
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
Test::Loop.before_each_test.push lambda {
|test_file, log_file, test_names|
CoverMe.config do |c|
c.project.store = test_file + '.coverage.data'
c.html_formatter.output_path = test_file + '.coverage'
end
}
Starting CoverMe in a worker process just before it loads and runs a test/**_test.rb file from my Rails app test suite:
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
Test::Loop.before_each_test.push lambda {
|test_file, log_file, test_names|
require 'cover_me'
CoverMe.config do |c|
c.project.store = test_file + '.coverage.data'
c.html_formatter.output_path = test_file + '.coverage'
end
}
Starting CoverMe (after configuring its output locations) in a worker process just before it loads and runs a test/**_test.rb file from my Rails app test suite:
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
Test::Loop.before_each_test.push lambda {
|test_file, log_file, test_names|
require 'cover_me'
CoverMe.config do |c|
c.project.store = test_file + '.coverage.data'
c.html_formatter.output_path = test_file + '.coverage'
end
CoverMe.complete!
}
None of these worked; all workers write to the same coverage.data at the root of my Rails app. Any ideas?
Thanks for your consideration.
Yeah, it's not thread safe. I would love a patch if you have one.
Actually, test-loop uses processes, not threads, to run tests in parallel. The core issue is that the setting of CoverMe's configuration parameters is not taking effect. Any ideas?