Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project.store setting not honored in parallel #41

Open
sunaku opened this issue Apr 30, 2011 · 2 comments
Open

project.store setting not honored in parallel #41

sunaku opened this issue Apr 30, 2011 · 2 comments

Comments

@sunaku
Copy link

sunaku commented Apr 30, 2011

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.

@markbates
Copy link
Owner

Yeah, it's not thread safe. I would love a patch if you have one.

@sunaku
Copy link
Author

sunaku commented May 1, 2011

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants