tagrs

Crates.iotagrs
lib.rstagrs
version0.0.2
sourcesrc
created_at2024-09-27 20:44:47.649484
updated_at2024-10-01 18:09:23.058348
descriptionRust test tagging
homepage
repository
max_upload_size
id1389239
size42,593
Aliaksei Bialiauski (h1alexbel)

documentation

README

tagrs. Rust test tagging

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

just Crates.io Version codecov PDD status Hits-of-Code License

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.

How to use

Here is an example:

#[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:

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:

TTAG=slow,fast cargo test

or with *:

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. 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:

just full
Commit count: 0

cargo fmt