Closed manicmaniac closed 5 months ago
:wave:
Hi there,
yes it's still necessary. The at_fork
block will only be called if the process is forked. You still need to start SimpleCov for the main process under test.
In your example script you're simply calling the block stored in at_fork
although no process was forked. Also be mindful that at_fork
is a block you can set yourself so it doesn't need to have the default values.
Documentation for the feature could probably be better/more in depth :)
See https://github.com/simplecov-ruby/simplecov/blob/0260b1f309e76c8ed87731ebbc348b05d753b8a2/README.md#L650-L654
The document says
SimpleCov.start
should be called afterSimpleCov.at_fork
when we need to collect coverage of subprocesses.However, the current implementation of
SimpleCov.at_fork
internally callsSimpleCov.start
, so I'm wondering that manually invokingSimpleCov.start
is needed or not.https://github.com/simplecov-ruby/simplecov/blob/0260b1f309e76c8ed87731ebbc348b05d753b8a2/lib/simplecov/configuration.rb#L233-L245
As far as I tested, that manual
SimpleCov.start
seems not only unnecessary but misleading under some conditions.Let's say that you need to collect branch coverage of subprocess, you will read the document and write some code like the following:
It does not work because SimpleCov.start is already called without enabling branch coverage, and the latter invocation does not seem to overwrite the former configurations.