-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Fix an issue with the code coverage in Erlang.mk #246
Conversation
It seems that just purging away the meck generated module (in `meck:unload`) is not removing it from the cover data. Exporting the cover data using `cover:export/1` will also export data about the meck generated module. Erlang.mk [uses](https://github.com/ninenines/erlang.mk/blob/b8a27ab752389394bfdb8c15d1b69455c313991e/plugins/cover.mk#L52) the export & import flow to generate the HTML coverage report, so the report will show the purged module - which is not correct. This might be due to an issue in the coverage tool and it would be better to investigate and fix it there, but this fix shouldn't break anything, so I think it is acceptable.
Can you help me understand the problem a bit more? It seems this patch deletes the coverage data of the original module, which would delete any coverage collected before that module being mocked by Meck. Cover-compiling a module should result in that module being in the exported coverage data, even if it has been mocked in the meantime. What shouldn't be included in the coverage data is the executed lines of the mock itself during its replacement. |
We are seeing this with Ra:
Erlang.mk doesn't do anything special here except configure CT to enable code coverage via a spec file. Worth noting that trying to exclude the Meck modules results in the Meck modules being present in the coverdata file, but CT then has another pass at it and removes those modules when generating its own coverage log. Erlang.mk could have a similar extra pass when generating its own cover report. But perhaps the patch in this PR (or if it's not fully correct, an improved patch similar to this) is a better way to go, I can't really think of a benefit to having Meck related modules being in the code coverage data to begin with. |
I realize now that I misunderstood the original fix, which I thought would remove any measurement whatsoever on the renamed I'll merge and release this ASAP. |
Thank you! |
This is now released in 1.0.0. |
It seems that just purging away the meck generated module (in
meck:unload
) is not removing it from the cover data. Exporting the cover data usingcover:export/1
will also export data about the meck generated module. Erlang.mk uses the export & import flow to generate the HTML coverage report, so the report will show the purged module - which is not correct.This might be due to an issue in the coverage tool and it would be better to investigate and fix it there, but this fix shouldn't break anything, so I think it is acceptable.