|
3 | 3 |
|
4 | 4 | #![forbid(unsafe_code)] |
5 | 5 |
|
6 | | -//! `datatest-stable` is a very simple test harness intended to write data-driven tests, where |
7 | | -//! individual test cases are specified as files and not as code. Given: |
8 | | -//! * a test `my_test` that accepts a path as input |
| 6 | +//! `datatest-stable` is a test harness intended to write *file-driven* or *data-driven* tests, |
| 7 | +//! where individual test cases are specified as files and not as code. |
| 8 | +//! |
| 9 | +//! Given: |
| 10 | +//! |
| 11 | +//! * a test `my_test` that accepts a path, and optionally the contents as input |
9 | 12 | //! * a directory to look for files in |
10 | 13 | //! * a pattern to match files on |
11 | 14 | //! |
|
26 | 29 | //! |
27 | 30 | //! 2. Call the `datatest_stable::harness!(testfn, root, pattern)` macro with the following |
28 | 31 | //! parameters: |
29 | | -//! * `testfn` - The test function to be executed on each matching input. This function can be one of: |
| 32 | +//! |
| 33 | +//! * `testfn` - The test function to be executed on each matching input. This function can be one |
| 34 | +//! of: |
30 | 35 | //! * `fn(&Path) -> datatest_stable::Result<()>` |
31 | 36 | //! * `fn(&Utf8Path) -> datatest_stable::Result<()>` (`Utf8Path` is part of the |
32 | 37 | //! [`camino`](https://docs.rs/camino) library, and is re-exported here for convenience.) |
| 38 | +//! * `fn(&P, String) -> datatest_stable::Result<()>` where `P` is `Path` or `Utf8Path`. If the |
| 39 | +//! extra `String` parameter is specified, the contents of the file will be loaded and passed in |
| 40 | +//! as a string (erroring out if that failed). |
| 41 | +//! * `fn(&P, Vec<u8>) -> datatest_stable::Result<()>` where `P` is `Path` or `Utf8Path`. If the |
| 42 | +//! extra `Vec<u8>` parameter is specified, are specified, the contents of the file will be |
| 43 | +//! loaded and passed in as a `Vec<u8>` (erroring out if that failed). |
33 | 44 | //! * `root` - The path to the root directory where the input files (fixtures) live. This path is |
34 | 45 | //! relative to the root of the crate. |
35 | 46 | //! * `pattern` - the regex used to match against and select each file to be tested. |
|
51 | 62 | //! Ok(()) |
52 | 63 | //! } |
53 | 64 | //! |
54 | | -//! fn my_test_utf8(path: &Utf8Path) -> datatest_stable::Result<()> { |
| 65 | +//! fn my_test_utf8(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> { |
55 | 66 | //! // ... write test here |
56 | 67 | //! |
57 | 68 | //! Ok(()) |
@@ -85,7 +96,7 @@ pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; |
85 | 96 |
|
86 | 97 | /// Not part of the public API, just used for macros. |
87 | 98 | #[doc(hidden)] |
88 | | -pub use self::runner::{runner, Requirements, TestFn}; |
| 99 | +pub use self::runner::{runner, test_kinds, Requirements, TestFn}; |
89 | 100 | /// A re-export of this type from the `camino` crate, since it forms part of function signatures. |
90 | 101 | #[doc(no_inline)] |
91 | 102 | pub use camino::Utf8Path; |
0 commit comments