Skip to content

Commit

Permalink
fix README.md
Browse files Browse the repository at this point in the history
cargo sync-rdme seems to eat lines that begin with `#` even if they're `cfg()`,
which seems incorrect. This is a good workaround for now.
  • Loading branch information
sunshowers committed Dec 26, 2024
1 parent 6b6229a commit afe5eb3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,24 @@ case, you can use:
````rust
use datatest_stable::Utf8Path;

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

static FIXTURES: include_dir::Dir<'static> =
datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
// In the library itself:
pub mod fixtures {
#[cfg(feature = "testing")]
pub static FIXTURES: &str = "tests/files";

#[cfg(not(feature = "testing"))]
pub static FIXTURES: include_dir::Dir<'static> =
datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
}

// In the test:
fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
// ... write test here
Ok(())
}

datatest_stable::harness! {
{ test = my_test, root = &FIXTURES, pattern = r"^.*/*" },
{ test = my_test, root = &fixtures::FIXTURES, pattern = r"^.*/*" },
}
````

Expand Down
18 changes: 11 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,24 @@
#![cfg_attr(not(feature = "include-dir"), doc = "```rust,ignore")]
//! use datatest_stable::Utf8Path;
//!
//! #[cfg(feature = "testing")]
//! static FIXTURES: &str = "tests/files";
//!
//! #[cfg(not(feature = "testing"))]
//! static FIXTURES: include_dir::Dir<'static> =
//! datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
//! // In the library itself:
//! pub mod fixtures {
//! #[cfg(feature = "testing")]
//! pub static FIXTURES: &str = "tests/files";
//!
//! #[cfg(not(feature = "testing"))]
//! pub static FIXTURES: include_dir::Dir<'static> =
//! datatest_stable::include_dir!("$CARGO_MANIFEST_DIR/tests/files");
//! }
//!
//! // In the test:
//! fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
//! // ... write test here
//! Ok(())
//! }
//!
//! datatest_stable::harness! {
//! { test = my_test, root = &FIXTURES, pattern = r"^.*/*" },
//! { test = my_test, root = &fixtures::FIXTURES, pattern = r"^.*/*" },
//! }
//! ```
//!
Expand Down

0 comments on commit afe5eb3

Please sign in to comment.