https://github.com/h1alexbel/tagrs
Rust test tagging
https://github.com/h1alexbel/tagrs
rust test-run testing
Last synced: about 1 year ago
JSON representation
Rust test tagging
- Host: GitHub
- URL: https://github.com/h1alexbel/tagrs
- Owner: h1alexbel
- License: mit
- Created: 2024-09-27T14:07:39.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-15T17:20:49.000Z (over 1 year ago)
- Last Synced: 2025-03-26T00:11:16.236Z (over 1 year ago)
- Topics: rust, test-run, testing
- Language: Shell
- Homepage:
- Size: 28.3 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# tagrs. Rust test tagging
[](https://www.elegantobjects.org)
[](http://www.rultor.com/p/h1alexbel/tagrs)
[](https://www.jetbrains.com/idea/)
[](https://github.com/h1alexbel/tagrs/actions/workflows/just.yml)
[](https://crates.io/crates/tagrs)
[](https://codecov.io/github/h1alexbel/tagrs)
[](http://www.0pdd.com/p?name=h1alexbel/tagrs)
[](https://hitsofcode.com/view/github/h1alexbel/tagrs)
[](https://github.com/h1alexbel/tagrs/blob/master/LICENSE.txt)
`tagrs` is a tool for [Rust test] tagging.
**Motivation**. There was no such tool for Rust, that can run tests
conditionally, based on tags, similarly to JUnit's [@Tag][JUnit Tag].
## How to use
Here is an example:
```rust
#[cfg(test)]
mod tests {
use anyhow::Result;
use tagrs::tag;
use std::thread;
use std::time::Duration;
#[tag("fast")]
#[test]
fn runs_fast() -> Result<()> {
assert_eq!(1 + 1, 2);
Ok(())
}
#[tag("slow")]
#[test]
fn runs_slow() -> Result<()> {
thread::sleep(Duration::from_secs(2));
assert_eq!(2 + 2, 4);
Ok(())
}
#[tag("nightly")]
#[test]
fn runs_very_slow() -> Result<()> {
thread::sleep(Duration::from_mins(2));
assert_eq!(4 + 4, 8);
Ok(())
}
}
```
then run:
```bash
TTAG=fast cargo test
```
It should run only `runs_fast` test, while `runs_slow`, `runs_very_slow` will
be ignored.
You can run a group of tags as well. Either with:
```bash
TTAG=slow,fast cargo test
```
or with `*`:
```bash
TTAG=* cargo test
```
The former will run only tests that have `slow` or `fast` tag, while the latter
will run all tests.
## How to contribute?
Make sure that you have [Rust] and [just] installed on your system, then fork
this repository, make changes, send us a [pull request][guidelines]. We will
review your changes and apply them to the `master` branch shortly, provided
they don't violate our quality standards. To avoid frustration, before sending
us your pull request please run full build:
```bash
just full
```
[Rust test]: https://doc.rust-lang.org/book/ch11-01-writing-tests.html
[JUnit Tag]: https://junit.org/junit5/docs/5.0.2/api/org/junit/jupiter/api/Tag.html
[guidelines]: https://www.yegor256.com/2014/04/15/github-guidelines.html
[Rust]: https://www.rust-lang.org/tools/install
[just]: https://just.systems/man/en/chapter_4.html