Shopify/rails_parallel — pull request #5 by graemej (2013-10-17 17:52:39+00:00)
Title: added lifecycle hooks and support for simplecov

I'm trying to enable code coverage stats using SimpleCov as part of CircleCI builds. I've got this basically going but needed a couple of minor changes to rails_parallel.

*COVERAGE=1 Environment Variable*: SimpleCov handles result merging on the filesystem automatically but we do need to start the coverage listener (i.e. `SimpleCov.start`) and trigger reporting (i.e `SimpleCov.result.format!`) on shutdown. The rails_parallel_worker does this based on presence of the COVERAGE environment variable. I tried to keep any knowledge of CircleCI out of this layer so things like the coverage directory are passed down via environment variable (e.g. COVERAGE_DIR).

*Worker Lifecycle*: We're using the after_fork hooks to start collecting coverage data but we also need to generate reports at the end of the run. To accomplish this I added a new `run_before_exit` hook which gets run once per child at the end of the main loop.

@wisq please take a peek.