From 7a3627f15355076695244aaeeee27e7d1dc58091 Mon Sep 17 00:00:00 2001 From: jedarden Date: Sun, 5 Jul 2026 15:22:26 -0400 Subject: [PATCH] test(bf-1pxdm): implement PDF fixture discovery for forms tests Add discover_pdf_fixtures function to recursively find all PDF files in tests/fixtures/forms/ directory using walkdir. Includes test that prints discovered fixture names to stdout. Acceptance criteria: - walkdir is available in crates/pdftract-cli/Cargo.toml - discover_pdf_fixtures function returns Vec of discovered PDFs - test_discover_pdf_fixtures runs and prints fixture names - No compilation errors Closes bf-1pxdm. --- tests/forms_integration.rs | 51 +++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/tests/forms_integration.rs b/tests/forms_integration.rs index 5d25749..f4f8c2c 100644 --- a/tests/forms_integration.rs +++ b/tests/forms_integration.rs @@ -6,9 +6,52 @@ //! - Widget annotation processing //! - Form data encoding/decoding -// Placeholder module - tests will be added in subsequent beads +use std::path::{Path, PathBuf}; +use walkdir::WalkDir; -#[cfg(test)] -mod tests { - // Test functions will be added here +/// Discover all PDF files in the given directory recursively. +/// +/// # Arguments +/// * `fixtures_path` - Path to the fixtures directory to search +/// +/// # Returns +/// A `Vec` containing paths to all discovered PDF files +pub fn discover_pdf_fixtures>(fixtures_path: P) -> Vec { + let mut pdf_files = Vec::new(); + + let walker = WalkDir::new(fixtures_path) + .follow_links(false) + .into_iter() + .filter_map(|e| e.ok()) + .filter(|e| { + e.file_type().is_file() + && e.path().extension().map(|ext| ext == "pdf").unwrap_or(false) + }) + .map(|e| e.path().to_path_buf()); + + pdf_files.extend(walker); + pdf_files.sort(); + + pdf_files +} + +#[test] +fn test_discover_pdf_fixtures() { + let fixtures_dir = "tests/fixtures/forms"; + let pdf_files = discover_pdf_fixtures(fixtures_dir); + + println!("\n=== Discovered PDF Fixtures ==="); + if pdf_files.is_empty() { + println!("No PDF files found in {}", fixtures_dir); + } else { + for pdf_path in &pdf_files { + println!(" - {}", pdf_path.display()); + } + println!("Total: {} PDF file(s)", pdf_files.len()); + } + println!("==============================\n"); + + // Test that the function runs without errors + // (We don't assert a count since fixtures may be added/removed) + let _ = pdf_files; }