diff --git a/CHANGELOG.md b/CHANGELOG.md index c3c054968..42c461120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.3.1] - 2024-12-25 + +### Fixed + +Fixed documentation for `include_dir` invocations. They must typically be called +via `include_dir!("$CARGO_MANIFEST_DIR/path/to/data")`. + ## [0.3.0] - 2024-12-24 ### Added @@ -62,6 +69,7 @@ Previously, the test functions supported were `fn(&Path) -> Result<()>` and `fn( - Switched to the `fancy-regex` crate, which allows for matching against regexes with lookahead/behind and backreferences. Thanks [@webbdays](https://github.com/webbdays) for your first contribution! + - MSRV updated to Rust 1.66. ## [0.2.6] - 2024-04-09 @@ -143,6 +151,7 @@ There are no functional changes in this release. (Version 0.1.0 was yanked because of a metadata issue.) +[0.3.1]: https://github.com/nextest-rs/datatest-stable/releases/tag/datatest-stable-0.3.1 [0.3.0]: https://github.com/nextest-rs/datatest-stable/releases/tag/datatest-stable-0.3.0 [0.2.10]: https://github.com/nextest-rs/datatest-stable/releases/tag/datatest-stable-0.2.10 [0.2.9]: https://github.com/nextest-rs/datatest-stable/releases/tag/datatest-stable-0.2.9 diff --git a/README.md b/README.md index 11072f6d1..59ee6f6c1 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,8 @@ You can also use directories published as `static` items in upstream crates: use datatest_stable::{include_dir, Utf8Path}; // In the upstream crate: -pub static FIXTURES: include_dir::Dir<'static> = include_dir!("tests/files"); +pub static FIXTURES: include_dir::Dir<'static> = + include_dir!("$CARGO_MANIFEST_DIR/tests/files"); // In your test: fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> { @@ -190,7 +191,8 @@ use datatest_stable::Utf8Path; static FIXTURES: &str = "tests/files"; -static FIXTURES: include_dir::Dir<'static> = datatest_stable::include_dir!("tests/files"); +static FIXTURES: include_dir::Dir<'static> = + datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files"); fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> { // ... write test here diff --git a/src/lib.rs b/src/lib.rs index 1beeeb814..be444a6ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -152,7 +152,8 @@ //! use datatest_stable::{include_dir, Utf8Path}; //! //! // In the upstream crate: -//! pub static FIXTURES: include_dir::Dir<'static> = include_dir!("tests/files"); +//! pub static FIXTURES: include_dir::Dir<'static> = +//! include_dir!("$CARGO_MANIFEST_DIR/tests/files"); //! //! // In your test: //! fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> { @@ -189,7 +190,8 @@ //! static FIXTURES: &str = "tests/files"; //! //! #[cfg(not(feature = "testing"))] -//! static FIXTURES: include_dir::Dir<'static> = datatest_stable::include_dir!("tests/files"); +//! static FIXTURES: include_dir::Dir<'static> = +//! datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files"); //! //! fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> { //! // ... write test here diff --git a/tests/example.rs b/tests/example.rs index 1861499fa..4d6ece2d8 100644 --- a/tests/example.rs +++ b/tests/example.rs @@ -25,13 +25,13 @@ mod with_contents { /// Returns an `include_dir::Dir` instance. macro_rules! maybe_include_dir { () => { - include_dir::include_dir!("tests/files") + include_dir::include_dir!("$CARGO_MANIFEST_DIR/tests/files") }; } /// A `&'static include_dir::Dir` instance. pub(crate) static MAYBE_INCLUDE_STATIC: include_dir::Dir = - include_dir::include_dir!("tests/files"); + include_dir::include_dir!("$CARGO_MANIFEST_DIR/tests/files"); pub(crate) fn test_artifact_string(path: &Path, contents: String) -> Result<()> { compare_contents(path, contents.as_bytes())