Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
coverage_attribute has been stabilized, deprecate this crate
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Dec 18, 2024
1 parent a045ac8 commit 788c111
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ keywords = ["macros", "attribute", "coverage", "testing"]
categories = ["development-tools::testing"]
exclude = ["/.*", "/tools"]
description = """
Helper for <https://github.com/taiki-e/cargo-llvm-cov/issues/123>.
Helper for <https://github.com/taiki-e/cargo-llvm-cov/issues/123>. (deprecated)
"""

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[badges]
maintenance = { status = "deprecated" }

[lib]
proc-macro = true

Expand Down
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,24 @@
[![license](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue?style=flat-square)](#license)
[![msrv](https://img.shields.io/badge/msrv-1.38-blue?style=flat-square&logo=rust)](https://www.rust-lang.org)
[![github actions](https://img.shields.io/github/actions/workflow/status/taiki-e/coverage-helper/ci.yml?branch=main&style=flat-square&logo=github)](https://github.com/taiki-e/coverage-helper/actions)
![maintenance-status](https://img.shields.io/badge/maintenance-deprecated-red?style=flat-square)

<!-- tidy:crate-doc:start -->

**Note: This crate is now deprecated in favor of the pattern that is [recommended in the cargo-llvm-cov documentation](https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#exclude-code-from-coverage).**

> If you want to ignore all `#[test]`-related code, you can use module-level `#[coverage(off)]` attribute:
>
> ```rust
> #[cfg(test)]
> #[cfg_attr(coverage, coverage(off))]
> mod tests {
> // ...
> }
> ```
>
> 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.
Helper for <https://github.com/taiki-e/cargo-llvm-cov/issues/123>.
**Note:** coverage-helper 0.2 supports `#[coverage(off)]`.
Expand All @@ -18,13 +34,7 @@ Add this to your `Cargo.toml`:
```toml
[dev-dependencies]
coverage-helper = "0.1"
```

And add this to your crate root (`lib.rs` or `main.rs`):

```rust
#![cfg_attr(all(coverage_nightly, test), feature(coverage_attribute))]
coverage-helper = "0.2"
```
## Examples
Expand Down
29 changes: 22 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

/*!
<!-- tidy:crate-doc:start -->
**Note: This crate is now deprecated in favor of the pattern that is [recommended in the cargo-llvm-cov documentation](https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#exclude-code-from-coverage).**
> If you want to ignore all `#[test]`-related code, you can use module-level `#[coverage(off)]` attribute:
>
> ```rust
> #[cfg(test)]
> #[cfg_attr(coverage, coverage(off))]
> mod tests {
> // ...
> }
> ```
>
> 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.
Helper for <https://github.com/taiki-e/cargo-llvm-cov/issues/123>.
**Note:** coverage-helper 0.2 supports `#[coverage(off)]`.
Expand All @@ -13,13 +28,7 @@ Add this to your `Cargo.toml`:
```toml
[dev-dependencies]
coverage-helper = "0.1"
```
And add this to your crate root (`lib.rs` or `main.rs`):
```rust
#![cfg_attr(all(coverage_nightly, test), feature(coverage_attribute))]
coverage-helper = "0.2"
```
## Examples
Expand Down Expand Up @@ -55,6 +64,12 @@ fn my_test() {
))]
#![forbid(unsafe_code)]
#![allow(clippy::test_attr_in_doctest)]
#![deprecated(
since = "0.2.3",
note = "this crate is deprecated in favor of module-level #[coverage(off)] attribute; \
see <https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#exclude-code-from-coverage> \
for more"
)]

// older compilers require explicit `extern crate`.
#[allow(unused_extern_crates)]
Expand Down
1 change: 0 additions & 1 deletion tests/basic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

#![cfg_attr(all(coverage_nightly, test), feature(coverage_attribute))]
#![allow(dead_code)]

#[coverage_helper::test]
Expand Down

0 comments on commit 788c111

Please sign in to comment.