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

Test coverage #4596

Merged
merged 5 commits into from Apr 11, 2024
Merged

Test coverage #4596

merged 5 commits into from Apr 11, 2024

Conversation

dullbananas
Copy link
Collaborator

Ability to notice untested code can increase the chance of fixing mistakes like the one noticed in #4560

export LEMMY_CONFIG_LOCATION=../../config/config.hjson
export RUST_BACKTRACE=1

cargo install cargo-llvm-cov
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if this cargo install should be here

Copy link
Member

Choose a reason for hiding this comment

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

Seems to be okay, its not doing a reinstall.

Copy link
Member

Choose a reason for hiding this comment

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

If this ever gets run from CI, I'd recommend cargo binstall like we have with some of the others.

@dullbananas dullbananas marked this pull request as ready for review April 4, 2024 23:47
export RUST_BACKTRACE=1

cargo install cargo-llvm-cov
cargo llvm-cov --workspace --all-features --no-fail-fast --lcov --output-path lcov.info
Copy link
Member

Choose a reason for hiding this comment

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

Im not sure how to open the lcov file. Why not use --html --open?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lcov file can be used to show coverage in the code editor (e.g. with coverage gutters extension for vscode)

Copy link
Member

Choose a reason for hiding this comment

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

Would be good if you explain that in a comment. I tried the gutters extension but it fails to find the coverage file, even after I manually configure it to use lcov.info. Can you share your plugin config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm using the default config.

Did you click "Watch" at the bottom and open a Rust file? If it says "No Coverage" then that's just referring to the current file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added comment

Copy link
Member

Choose a reason for hiding this comment

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

After clicking "watch" there is an error message "Could not find a Coverage file! Searched for lcov.info, cov.xml, coverage.xml, jacoco.xml, coverage.cobertura.xml". But lcov.info definitely exists and the open file has various tests, so no idea what the problem is. Im using VSCodium in case that makes a difference.

@Nutomic
Copy link
Member

Nutomic commented Apr 5, 2024

It might also be interesting to consider api tests for coverage. Should be possible with cargo llvm-cov run and then merge the different reports.

.gitignore Outdated
@@ -34,3 +34,6 @@ dev_pgdata/

# database dumps
*.sqldump

# test coverage
lcov.info
Copy link
Member

Choose a reason for hiding this comment

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

I would put this in the target folder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

export LEMMY_CONFIG_LOCATION=../../config/config.hjson
export RUST_BACKTRACE=1

cargo install cargo-llvm-cov
Copy link
Member

Choose a reason for hiding this comment

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

If this ever gets run from CI, I'd recommend cargo binstall like we have with some of the others.

@dessalines dessalines requested a review from Nutomic April 10, 2024 14:16
@Nutomic Nutomic merged commit 0f6b13a into LemmyNet:main Apr 11, 2024
1 check passed
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.

None yet

4 participants