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

fix: calculation of coverage percentage #403

Closed
wants to merge 1 commit into from
Closed

Conversation

a1div0
Copy link
Collaborator

@a1div0 a1div0 commented Nov 13, 2024

The following small pull request fixes the issue with calculating the test coverage percentage. To achieve this, instead of initializing with an empty statistics list, it is populated with all Lua files from the LUATESTLUACOVROOT directory (by default, this is the project directory).

The CHANGELOG has been updated.

@a1div0 a1div0 requested review from Totktonada and locker November 13, 2024 13:53
@a1div0 a1div0 self-assigned this Nov 13, 2024
@a1div0 a1div0 requested review from locker and Totktonada November 13, 2024 13:57
@@ -23,6 +23,7 @@
- Fix error trace reporting for functions executed with `Server:exec()`
(gh-396).
- Remove pretty-printing of `luatest.log` arguments.
- Fixed calculation of coverage percentage (gh-402)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad changelog - unclear what exactly was wrong. Would be nice to say that it added uncovered files to the coverage report.

Also, please write a descriptive commit message. It should include Closes #XXX. We don't start subject lines with "fix: ...". Should probably be "Add uncovered files to coverage report".

@@ -42,6 +53,10 @@ function export.enable()
for _, item in pairs(export.DEFAULT_EXCLUDE) do
table.insert(config.exclude, item)
end

runner.data = {}
find_luas(runner.data, root)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing undocumented fields of luacov.runner. looks dangerous. At least, this requires a comment.

The only alternative I see is writing a coverage report file with zero counters before initializing luacov.runner. This could be done with luacov.stats.save.

@Totktonada WDYT?

@a1div0
Copy link
Collaborator Author

a1div0 commented Nov 14, 2024

Sorry, this has already been fixed here

@a1div0 a1div0 closed this Nov 14, 2024
@a1div0 a1div0 deleted the aklenov/coverage_fix branch November 14, 2024 09:08
@Totktonada Totktonada removed their request for review November 14, 2024 10:35
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.

The calculation of test coverage percentage does not account for all source files
3 participants