Closed albertored closed 1 year ago
I will fix and add tests if you think the feature is ok
Thanks and sorry being late to respond. Is it possible for you to provide example for this option for understanding the scenario better? (document, example code, etc.)
@parroty I'll use the example taken from mix test.coverage to explain the changes.
Imagine you want to run tests split in different partitions, at the moment you won't get the real coverage from excoveralls since the only a subset of tests is ran in each partition. With this change, we mimic the behavior of mix by exporting .coverdata
files in the first runs and importing them in the last run to have a full coverage report.
MIX_TEST_PARTITION=1 mix coveralls --partitions 3 --export-coverage part1
MIX_TEST_PARTITION=2 mix coveralls --partitions 3 --export-coverage part2
MIX_TEST_PARTITION=3 mix coveralls --partitions 3 --import-cover cover
The first 2 commands generate cover/part1.coverdata
and cover/part2.coverdata
files that are then imported by the last command to generate a full report.
Another example, similar to my use case, is when you want to test your application with something different from mix
. Imagine to use mix test
for unit tests and then have some other tool that performs some integration test. By directly calling the :cover
erlang module you can generate .coverdata
report from your integrations tests and then use mix coveralls --import-cover cover
to run unit tests and include the integration tests report in the final coverage.
Hi @parroty, did you manage to take a look at the provided example? In the next days, I will add documentation and tests
Hi @parroty, just noticed that you merged #298 which implements half of my PR. I have rebased on top of that keeping only the part for importing coverage outputs, fixed tests and added the new option to the README. It should now be ready to be merged.
Thanks for the additional work, and sorry being late to respond 🙇 .
This PR aims to handle the generation and import of coverage data.
For generation, we need to handle the
:export
and:output
options given toExCoveralls.start/2
function. These options are described in Mix documentation for test.coverage.For import, I added a new command line option (
--import-cover
) for selecting a directory from where cover data should be loaded. These files will be imported after module cover-compilation and their data will be added to the generated report.