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:
189189```` rust
190190use datatest_stable :: Utf8Path ;
191191
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+ }
196201
202+ // In the test:
197203fn my_test (path : & Utf8Path , contents : String ) -> datatest_stable :: Result <()> {
198204 // ... write test here
199205 Ok (())
200206}
201207
202208datatest_stable :: harness! {
203- { test = my_test , root = & FIXTURES , pattern = r " ^.*/*" },
209+ { test = my_test , root = & fixtures :: FIXTURES , pattern = r " ^.*/*" },
204210}
205211````
206212
Original file line number Diff line number Diff line change 186186#![ cfg_attr( not( feature = "include-dir" ) , doc = "```rust,ignore" ) ]
187187//! use datatest_stable::Utf8Path;
188188//!
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+ //! }
195198//!
199+ //! // In the test:
196200//! fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
197201//! // ... write test here
198202//! Ok(())
199203//! }
200204//!
201205//! datatest_stable::harness! {
202- //! { test = my_test, root = &FIXTURES, pattern = r"^.*/*" },
206+ //! { test = my_test, root = &fixtures:: FIXTURES, pattern = r"^.*/*" },
203207//! }
204208//! ```
205209//!
You can’t perform that action at this time.
0 commit comments