Skip to main content

test_with/
lib.rs

1//! `test_with` provides [macro@env], [macro@file], [macro@path], [macro@http], [macro@https],
2//! [macro@icmp], [macro@tcp], [macro@root], [macro@group], [macro@user], [macro@mem], [macro@swap],
3//! [macro@cpu_core], [macro@phy_core], [macro@executable], [macro@timezone] macros to help you run
4//! test case only with the condition is fulfilled.  If the `#[test]` is absent for the test case,
5//! `#[test_with]` will add it to the test case automatically.
6//!
7//! This crate help you easier make integrating test case and has a good cargo summary on CI server,
8//! and will not affect on your binary output when you dependent it as dev-dependency as following.
9//! ```toml
10//! [dev-dependencies]
11//! test-with = "*"
12//! ```
13//! All features will be opt-in default feature, so this crate will be easier to use, if you using
14//! a CI server with really limitation resource and want this crate as slim as possible, you can
15//! select the feature you want as following.
16//! ```toml
17//! [dev-dependencies]
18//! test-with = { version = "*", default-features = false, features = ["net"] }
19//! ```
20//!
21//! The solution to have a real runtime condition check, we need to put the test as normal function
22//! as an example, then use `cargo run --example`
23//! The `test-with` need be included as normal dependency with `runtime` feature.
24//! And also include the `test-with` as normal dependency (not dev-dependency) corresponding
25//! features in `Cargo.toml`
26//! [macro@runner] and [macro@module] are for the basic skeleton of the test runner.
27//! [macro@runtime_env], [macro@runtime_no_env], [macro@runtime_file], [macro@runtime_path],
28//! [macro@runtime_http], [macro@runtime_https], [macro@runtime_icmp], [macro@runtime_tcp],
29//! [macro@runtime_root], [macro@runtime_group], [macro@runtime_user], [macro@runtime_mem],
30//! [macro@runtime_free_mem], [macro@runtime_available_mem], [macro@runtime_swap],
31//! [macro@runtime_free_swap], [macro@runtime_available_swap], [macro@runtime_cpu_core],
32//! [macro@runtime_phy_core], [macro@runtime_executable], [macro@runtime_timezone]
33//! and [macro@runtime_ignore_if] are used to transform a normal function to a testcase.
34//! The libtest-mimic support runtime ignore after 0.8.2, we do not need libtest-with any more,
35//! and all runtime feature is still compatible and easy to use.
36//!
37//! ```toml
38//! [dependencies]
39//! test-with = { version = "*", default-features = false, features = ["runtime"] }
40//! ```
41//!
42//! ```rust
43//! // write as example in examples/*rs
44//! test_with::runner!(env);
45//! #[test_with::module]
46//! mod env {
47//! #[test_with::runtime_env(PWD)]
48//! fn test_works() {
49//!     assert!(true);
50//!     }
51//! }
52//! ```
53
54pub use test_with_derive::*;
55
56#[cfg(feature = "runtime")]
57pub use libtest_mimic::*;
58
59#[cfg(all(feature = "runtime", feature = "resource"))]
60pub use byte_unit;
61#[cfg(all(feature = "runtime", feature = "timezone"))]
62pub use chrono;
63#[cfg(all(feature = "runtime", feature = "resource"))]
64pub use num_cpus;
65#[cfg(all(feature = "runtime", feature = "icmp"))]
66pub use ping;
67#[cfg(all(feature = "runtime", feature = "http"))]
68pub use reqwest;
69#[cfg(all(feature = "runtime", feature = "resource"))]
70pub use sysinfo;
71#[cfg(all(feature = "runtime", feature = "user", not(target_os = "windows")))]
72pub use uzers;
73#[cfg(all(feature = "runtime", feature = "executable"))]
74pub use which;