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

Import coverdata if needed #292

Merged
merged 1 commit into from
Jan 24, 2023
Merged

Import coverdata if needed #292

merged 1 commit into from
Jan 24, 2023

Conversation

albertored
Copy link
Contributor

@albertored albertored commented Oct 17, 2022

This PR aims to handle the generation and import of coverage data.

For generation, we need to handle the :export and :output options given to ExCoveralls.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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 88.113% when pulling 7d6345b on albertored:coverdata into d1b6b35 on parroty:master.

@coveralls
Copy link

coveralls commented Oct 17, 2022

Coverage Status

Coverage: 88.015% (-1.2%) from 89.184% when pulling 0e88da0 on albertored:coverdata into 2dc17fd on parroty:master.

@albertored
Copy link
Contributor Author

I will fix and add tests if you think the feature is ok

@parroty
Copy link
Owner

parroty commented Nov 27, 2022

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.)

@albertored
Copy link
Contributor Author

albertored commented Nov 30, 2022

@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.

@albertored
Copy link
Contributor Author

Hi @parroty, did you manage to take a look at the provided example? In the next days, I will add documentation and tests

@albertored albertored changed the title Import and export coverdata if needed Import coverdata if needed Jan 20, 2023
@albertored
Copy link
Contributor Author

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.

@parroty parroty merged commit 5cbf759 into parroty:master Jan 24, 2023
@parroty
Copy link
Owner

parroty commented Jan 24, 2023

Thanks for the additional work, and sorry being late to respond 🙇 .

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

Successfully merging this pull request may close these issues.

3 participants