File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -189,18 +189,24 @@ case, you can use:
189
189
```` rust
190
190
use datatest_stable :: Utf8Path ;
191
191
192
- static FIXTURES : & str = " tests/files" ;
193
-
194
- static FIXTURES : include_dir :: Dir <'static > =
195
- datatest_stable :: include_dir! (" $CARGO_MANIFEST_DIR/tests/files" );
192
+ // In the library itself:
193
+ pub mod fixtures {
194
+ #[cfg(feature = " testing" )]
195
+ pub static FIXTURES : & str = " tests/files" ;
196
+
197
+ #[cfg(not(feature = " testing" ))]
198
+ pub static FIXTURES : include_dir :: Dir <'static > =
199
+ datatest_stable :: include_dir! (" $CARGO_MANIFEST_DIR/tests/files" );
200
+ }
196
201
202
+ // In the test:
197
203
fn my_test (path : & Utf8Path , contents : String ) -> datatest_stable :: Result <()> {
198
204
// ... write test here
199
205
Ok (())
200
206
}
201
207
202
208
datatest_stable :: harness! {
203
- { test = my_test , root = & FIXTURES , pattern = r " ^.*/*" },
209
+ { test = my_test , root = & fixtures :: FIXTURES , pattern = r " ^.*/*" },
204
210
}
205
211
````
206
212
Original file line number Diff line number Diff line change 186
186
#![ cfg_attr( not( feature = "include-dir" ) , doc = "```rust,ignore" ) ]
187
187
//! use datatest_stable::Utf8Path;
188
188
//!
189
- //! #[cfg(feature = "testing")]
190
- //! static FIXTURES: &str = "tests/files";
191
- //!
192
- //! #[cfg(not(feature = "testing"))]
193
- //! static FIXTURES: include_dir::Dir<'static> =
194
- //! datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
189
+ //! // In the library itself:
190
+ //! pub mod fixtures {
191
+ //! #[cfg(feature = "testing")]
192
+ //! pub static FIXTURES: &str = "tests/files";
193
+ //!
194
+ //! #[cfg(not(feature = "testing"))]
195
+ //! pub static FIXTURES: include_dir::Dir<'static> =
196
+ //! datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
197
+ //! }
195
198
//!
199
+ //! // In the test:
196
200
//! fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
197
201
//! // ... write test here
198
202
//! Ok(())
199
203
//! }
200
204
//!
201
205
//! datatest_stable::harness! {
202
- //! { test = my_test, root = &FIXTURES, pattern = r"^.*/*" },
206
+ //! { test = my_test, root = &fixtures:: FIXTURES, pattern = r"^.*/*" },
203
207
//! }
204
208
//! ```
205
209
//!
You can’t perform that action at this time.
0 commit comments