testdata/lib.rs
1//! Macros and helper functions for file-based testing.
2//!
3//! ## Example
4//!
5//! The crate's main feature is [`testdata::files`], which automatically
6//! finds test files and expands to multiple tests.
7//!
8//! ```rust
9//! use std::str;
10//! use testdata::{assert_snapshot, TestFile};
11//!
12//! #[testdata::files(rebuild = "tests/example.rs")]
13//! #[test]
14//! fn test_foo(
15//! #[glob = "tests/fixtures/**/*-in.txt"] input: &TestFile,
16//! #[glob = "tests/fixtures/**/*-out.txt"] output: &TestFile,
17//! ) {
18//! let s = input.raw_read();
19//! let s = str::from_utf8(&s).unwrap();
20//! let result = s.to_uppercase();
21//! assert_snapshot!(result, snapshot = output);
22//! }
23//! ```
24//!
25//! More documents will be added in the later versions.
26
27pub use testdata_macros::files;
28pub use testdata_rt::*;
29
30pub mod __rt {
31 pub use once_cell::sync::Lazy;
32 pub use testdata_rt::{touch, ArgSpec, GlobSpec};
33}