You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To exclude the specific function from coverage, use the [`#[coverage(off)]` attribute][rust-lang/rust#84605].
490
+
To exclude the specific function or module from coverage, use the [`#[coverage(off)]` attribute][rust-lang/rust#84605].
491
491
492
-
Since `#[coverage(off)]`is unstable, it is recommended to use it together with `cfg(coverage)` or `cfg(coverage_nightly)` set by cargo-llvm-cov.
492
+
Since `#[coverage(off)]`attribute stabilized in Rust 1.85, it is recommended to use it together with `cfg(coverage)` or `cfg(coverage_nightly)` set by cargo-llvm-cov for compatibility with old Rust.
If you want to ignore all `#[test]`-related code, consider using [coverage-helper] crate version 0.2+.
520
+
If you want to ignore all `#[test]`-related code, you can use module-level `#[coverage(off)]` attribute:
516
521
517
-
cargo-llvm-cov excludes code contained in the directory named `tests` from the report by default, so you can also use it instead of coverage-helper crate.
522
+
```rust
523
+
#[cfg(test)]
524
+
#[cfg_attr(coverage, coverage(off))]
525
+
modtests {
526
+
// ...
527
+
}
528
+
```
518
529
519
-
**Note:**`#[coverage(off)]` was previously named `#[no_coverage]`. When using `#[no_coverage]` in the old nightly, replace `feature(coverage_attribute)` with `feature(no_coverage)`, `coverage(off)` with `no_coverage`, and `coverage-helper` 0.2+ with `coverage-helper` 0.1.
530
+
cargo-llvm-cov excludes code contained in the directory named `tests` from the report by default, so you can also use it instead of `#[coverage(off)]` attribute.
520
531
521
532
### Continuous Integration
522
533
@@ -716,21 +727,18 @@ See also [the code-coverage-related issues reported in rust-lang/rust](https://g
716
727
717
728
## Related Projects
718
729
719
-
- [coverage-helper]: Helper for [#123].
720
730
- [cargo-config2]: Library to load and resolve Cargo configuration. cargo-llvm-cov uses this library.
721
731
- [cargo-hack]: Cargo subcommand to provide various options useful for testing and continuous integration.
722
732
- [cargo-minimal-versions]: Cargo subcommand for proper use of `-Z minimal-versions`.
0 commit comments