Skip to content

Commit 6b6229a

Browse files
committed
fix include_dir invocations
Must pass in `$CARGO_MANIFEST_DIR`.
1 parent 192e0d9 commit 6b6229a

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.3.1] - 2024-12-25
4+
5+
### Fixed
6+
7+
Fixed documentation for `include_dir` invocations. They must typically be called
8+
via `include_dir!("$CARGO_MANIFEST_DIR/path/to/data")`.
9+
310
## [0.3.0] - 2024-12-24
411

512
### Added
@@ -62,6 +69,7 @@ Previously, the test functions supported were `fn(&Path) -> Result<()>` and `fn(
6269
- Switched to the `fancy-regex` crate, which allows for matching against regexes with
6370
lookahead/behind and backreferences. Thanks [@webbdays](https://github.com/webbdays) for your
6471
first contribution!
72+
6573
- MSRV updated to Rust 1.66.
6674

6775
## [0.2.6] - 2024-04-09
@@ -143,6 +151,7 @@ There are no functional changes in this release.
143151

144152
(Version 0.1.0 was yanked because of a metadata issue.)
145153

154+
[0.3.1]: https://github.com/nextest-rs/datatest-stable/releases/tag/datatest-stable-0.3.1
146155
[0.3.0]: https://github.com/nextest-rs/datatest-stable/releases/tag/datatest-stable-0.3.0
147156
[0.2.10]: https://github.com/nextest-rs/datatest-stable/releases/tag/datatest-stable-0.2.10
148157
[0.2.9]: https://github.com/nextest-rs/datatest-stable/releases/tag/datatest-stable-0.2.9

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ You can also use directories published as `static` items in upstream crates:
156156
use datatest_stable::{include_dir, Utf8Path};
157157

158158
// In the upstream crate:
159-
pub static FIXTURES: include_dir::Dir<'static> = include_dir!("tests/files");
159+
pub static FIXTURES: include_dir::Dir<'static> =
160+
include_dir!("$CARGO_MANIFEST_DIR/tests/files");
160161

161162
// In your test:
162163
fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
@@ -190,7 +191,8 @@ use datatest_stable::Utf8Path;
190191

191192
static FIXTURES: &str = "tests/files";
192193

193-
static FIXTURES: include_dir::Dir<'static> = datatest_stable::include_dir!("tests/files");
194+
static FIXTURES: include_dir::Dir<'static> =
195+
datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
194196

195197
fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
196198
// ... write test here

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@
152152
//! use datatest_stable::{include_dir, Utf8Path};
153153
//!
154154
//! // In the upstream crate:
155-
//! pub static FIXTURES: include_dir::Dir<'static> = include_dir!("tests/files");
155+
//! pub static FIXTURES: include_dir::Dir<'static> =
156+
//! include_dir!("$CARGO_MANIFEST_DIR/tests/files");
156157
//!
157158
//! // In your test:
158159
//! fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
@@ -189,7 +190,8 @@
189190
//! static FIXTURES: &str = "tests/files";
190191
//!
191192
//! #[cfg(not(feature = "testing"))]
192-
//! static FIXTURES: include_dir::Dir<'static> = datatest_stable::include_dir!("tests/files");
193+
//! static FIXTURES: include_dir::Dir<'static> =
194+
//! datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
193195
//!
194196
//! fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
195197
//! // ... write test here

tests/example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ mod with_contents {
2525
/// Returns an `include_dir::Dir` instance.
2626
macro_rules! maybe_include_dir {
2727
() => {
28-
include_dir::include_dir!("tests/files")
28+
include_dir::include_dir!("$CARGO_MANIFEST_DIR/tests/files")
2929
};
3030
}
3131

3232
/// A `&'static include_dir::Dir` instance.
3333
pub(crate) static MAYBE_INCLUDE_STATIC: include_dir::Dir =
34-
include_dir::include_dir!("tests/files");
34+
include_dir::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
3535

3636
pub(crate) fn test_artifact_string(path: &Path, contents: String) -> Result<()> {
3737
compare_contents(path, contents.as_bytes())

0 commit comments

Comments
 (0)