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_ip_in],
29//! [macro@runtime_public_ip], [macro@runtime_public_ip_in], [macro@runtime_public_ip_is],
30//! [macro@runtime_tcp],
31//! [macro@runtime_root], [macro@runtime_group], [macro@runtime_user], [macro@runtime_mem],
32//! [macro@runtime_free_mem], [macro@runtime_available_mem], [macro@runtime_swap],
33//! [macro@runtime_free_swap], [macro@runtime_available_swap], [macro@runtime_cpu_core],
34//! [macro@runtime_phy_core], [macro@runtime_executable], [macro@runtime_timezone]
35//! and [macro@runtime_ignore_if] are used to transform a normal function to a testcase.
36//! The libtest-mimic support runtime ignore after 0.8.2, we do not need libtest-with any more,
37//! and all runtime feature is still compatible and easy to use.
38//!
39//! ```toml
40//! [dependencies]
41//! test-with = { version = "*", default-features = false, features = ["runtime"] }
42//! ```
43//!
44//! ```rust
45//! // write as example in examples/*rs
46//! test_with::runner!(env);
47//! #[test_with::module]
48//! mod env {
49//! #[test_with::runtime_env(PWD)]
50//! fn test_works() {
51//! assert!(true);
52//! }
53//! }
54//! ```
55
56pub use test_with_derive::*;
57
58#[cfg(feature = "runtime")]
59pub use libtest_mimic::*;
60
61#[cfg(all(feature = "runtime", feature = "resource"))]
62pub use byte_unit;
63#[cfg(all(feature = "runtime", feature = "timezone"))]
64pub use chrono;
65#[cfg(all(feature = "runtime", feature = "ip"))]
66pub use ipnet;
67#[cfg(all(feature = "runtime", feature = "ip"))]
68pub use local_ip_address;
69#[cfg(all(feature = "runtime", feature = "resource"))]
70pub use num_cpus;
71#[cfg(all(feature = "runtime", feature = "icmp"))]
72pub use ping;
73#[cfg(all(feature = "runtime", any(feature = "http", feature = "ip")))]
74pub use reqwest;
75#[cfg(all(feature = "runtime", feature = "resource"))]
76pub use sysinfo;
77#[cfg(all(feature = "runtime", feature = "user", not(target_os = "windows")))]
78pub use uzers;
79#[cfg(all(feature = "runtime", feature = "executable"))]
80pub use which;