Skip to content

add link to coverage reports

trinity-1686a requested to merge trinity-1686a/arti:link-to-coverage into main

fix #251 (closed)

I suggest the text of #400 be updated to as a few things changed about coverage since it was wrote. Notably we now have coverage reports hosted somewhere, we only require a recent rust, not nightly (although nightly still works), and the path to the generated file changed slightly. (cc @nickm as its his issue)

*(This is a placeholder ticket, made so that people can find it when they search for things to do under the ~"First Contribution" label.)*

We try to use coverage tools to check how well our test code actually reaches all of our functions. Coverage reports are [uploaded daily](https://tpo.pages.torproject.net/core/arti/coverage/). To test your own changes, you'll need to install a few tools:

1. Use rustup to update to a recent rust version (1.60 or newer), if you haven't done so already: `rustup update`.
1. Install the grcov prerequisites and tools:
   * `rustup component add llvm-tools-preview`
   * `cargo install grcov`
   * (if you run into trouble, see the [grcov documentation](https://github.com/mozilla/grcov#how-to-get-grcov).)
1. In the arti source repository, run: `./maint/coverage unit`. This may take a long time.
1. Load in the newly created `coverage/all/index.html` file in your web browser, and you can inspect Arti's code coverage!

---

When you're writing new tests, make sure that your tests actually *test* the code that they're calling. It's no good to increase coverage just by *calling* the underlying code: a good test needs to make sure that the code works.

As a general rule, ask yourself: Would this test still pass if the code did the wrong thing? The answer should be "no".

Also ask yourself: would this test fail if the code did the right thing, but in a different way than it does now? Ideally, the answer should be "yes".

Merge request reports