-
Notifications
You must be signed in to change notification settings - Fork 149
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
Documentation improvement #249
Comments
Here's a related Rust Users forum topic I've just created: https://users.rust-lang.org/t/test-coverage-with-grcov/24851 |
Thanks @dalibor-matura! You can use the Travis or Appveyor config as examples (since we are collecting coverage for grcov itself). |
@calixteman improved the docs a little by adding an example of how to use grcov on Travis with #250. |
Thanks for the info @marco-c and thanks to @calixteman for the documentation improvement: https://github.com/mozilla/grcov#grcov-with-travis I already tried it a few days ago, but got into problems with the coverage itself: https://users.rust-lang.org/t/test-coverage-with-grcov/24851/8?u=dalibor, so I'm still using the |
If you want to remove yellow lines, you can remove --branch option from grcov. A yellow line can be an interesting information: fn first_is(&self, c: u8) -> bool {
!self.buf.is_empty() && self.buf[0] == c
} here this line is yellow because there is an extra check when getting self.buf[0] and of course we never fail and so never take the else branch of the check. This check is useless since we checked just before that the buf is not empty. So let's rewrite it to remove useless check and so have green lines: fn first_is(&self, c: u8) -> bool {
if let Some(cc) = self.buf.get(0) {
*cc == c
} else {
false
}
} On an easy case like this, probably the optimizer in LLVM will be able to remove redundant checks, but sometimes it's pretty hard so it's probably better to try to write good code. |
I have read the travis example and still can not make grov work for my local project (using
|
@Fubuchi, I added coverage for an other project: |
@calixteman I tweak the command a bit to make it work on windows powershell and install WSL to get the genhtml tool. |
Took me a while to get this going, so I thought I'd share my progress. Create a new project and go into the directory
Set the environment variables
Build Rust project and run tests
Create a directory, in which we store the code coverage files
Add the needed files into a zip. (${PWD##*/} equates to the directory name)
Generate the report.
Generate the html files. (genhtml is bundled with lcov, so you might have to install that)
Open the report in the browser.
For your aliases.zsh
|
You can try the new html output format: -t html and -o output_dir and give us some feedback on this output. |
@calixteman is the html supported it in the 0.5.3 version? I install grcov for windows from cargo, result in version 0.5.0 |
Yep it should be in 0.5.3: |
@TomLouisKeller just a detail to add is that rust nightly is mandatory. |
I have just tested the html output format, look very good 👍 . Hope the new version will come to crates.io soon |
I've released 0.5.1, 0.5.2, 0.5.3 and 0.5.4 (which changes |
@calixteman @marco-c Very nice, thank you =) |
These instructions are extremely helpful. Can someone please turn this issue into a documentation PR please? |
@gilescope can you? :) |
When I run those instructions I get the following error from rustc (during the
|
@Nokel81, probably related to: |
@calixteman Thanks, will try in a linux VM |
Hey guys, is there currently any way to print a report to the terminal? 😊 |
@fgimian the top level is printed to the terminal when genhtml is run if that helps - E.g.:
|
Also, it doesn't seem to be documented but |
Nice - less dependencies makes happier users. Yep that -t html seems to work fine. Great. |
According to doc we have to use these ( |
Glad to here it works in docker. Could be methodology differences on whitespace treatment or maybe branch versus line? (I am just guessing) Sent with GitHawk |
You could try source-based coverage, I've recently added support for it in grcov (version 0.6.0). Short explanation at https://marco-c.github.io/2020/11/24/rust-source-based-code-coverage.html, docs at https://github.com/mozilla/grcov#example-how-to-generate-source-based-coverage-for-a-rust-project, full example at https://github.com/marco-c/rust-code-coverage-sample. |
The Readme contains just a minimal usage information and almost no examples.
I would like to get my standard Rust
lib.rs
project connected with CodeCov (https://codecov.io/), so I would like to gather the Test Coverage data withgrcov
and send it to CodeCov.The only information provided on this topic in Readme is:
and I don't know what the directories should I used in my case instead of the
~/Documents/FD/mozilla-central/build
~/Documents/FD/mozilla-central
shouldIt would be nice to provide more detailed description. I'm willing to help and I've already cloned this repo and will look/search through the codebase to get better understanding how it works.
Thanks for a cool tool ;)
The text was updated successfully, but these errors were encountered: