From c3b09d706ff7be026831b1236c36ed0d8aa7250d Mon Sep 17 00:00:00 2001 From: tenzap <46226844+tenzap@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:41:55 +0100 Subject: [PATCH] fix build failure when running tests without cache feature (#209) --- pdf/examples/content.rs | 1 + pdf/examples/metadata.rs | 1 + pdf/examples/names.rs | 1 + pdf/examples/other_page_content.rs | 1 + pdf/examples/read.rs | 1 + pdf/tests/integration.rs | 2 +- 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pdf/examples/content.rs b/pdf/examples/content.rs index 7f90ea18..9652407a 100644 --- a/pdf/examples/content.rs +++ b/pdf/examples/content.rs @@ -14,6 +14,7 @@ use pdf::build::*; use pdf::primitive::PdfString; +#[cfg(feature="cache")] fn main() -> Result<(), PdfError> { let path = PathBuf::from(env::args_os().nth(1).expect("no file given")); diff --git a/pdf/examples/metadata.rs b/pdf/examples/metadata.rs index 3900d2a1..4fba7e96 100644 --- a/pdf/examples/metadata.rs +++ b/pdf/examples/metadata.rs @@ -5,6 +5,7 @@ use pdf::file::{FileOptions}; use pdf::object::{FieldDictionary, FieldType, Resolve}; /// extract and print a PDF's metadata +#[cfg(feature="cache")] fn main() -> Result<(), PdfError> { let path = args() .nth(1) diff --git a/pdf/examples/names.rs b/pdf/examples/names.rs index fe89f01a..82cd8b03 100644 --- a/pdf/examples/names.rs +++ b/pdf/examples/names.rs @@ -60,6 +60,7 @@ fn walk_outline(r: &impl Resolve, mut node: RcRef, name_map: &impl } } +#[cfg(feature="cache")] fn main() { let path = args().nth(1).expect("no file given"); println!("read: {}", path); diff --git a/pdf/examples/other_page_content.rs b/pdf/examples/other_page_content.rs index fbe31bc8..52ac4536 100644 --- a/pdf/examples/other_page_content.rs +++ b/pdf/examples/other_page_content.rs @@ -8,6 +8,7 @@ use std::env::args; /// Extract data from a page entry that is under "other". /// This example looks for stikethroughs in the annotations entry /// and returns a Vec for the bounds of the struckthrough text. +#[cfg(feature="cache")] fn main() -> Result<(), PdfError> { let path = args() .nth(1) diff --git a/pdf/examples/read.rs b/pdf/examples/read.rs index b4f4b619..c9d30c41 100644 --- a/pdf/examples/read.rs +++ b/pdf/examples/read.rs @@ -21,6 +21,7 @@ impl Log for VerboseLog { } } +#[cfg(feature="cache")] fn main() -> Result<(), PdfError> { let path = args().nth(1).expect("no file given"); println!("read: {}", path); diff --git a/pdf/tests/integration.rs b/pdf/tests/integration.rs index 94262311..fdfc9a30 100644 --- a/pdf/tests/integration.rs +++ b/pdf/tests/integration.rs @@ -21,7 +21,7 @@ macro_rules! run { #[test] fn open_file() { let _ = run!(FileOptions::uncached().open(file_path!("example.pdf"))); - #[cfg(feature = "mmap")] + #[cfg(all(feature = "mmap", feature = "cache"))] let _ = run!({ use memmap2::Mmap; let file = std::fs::File::open(file_path!("example.pdf")).expect("can't open file");