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<PathBuf> of discovered PDFs - test_discover_pdf_fixtures runs and prints fixture names - No compilation errors Closes bf-1pxdm.
This commit is contained in:
parent
17e7cfb81b
commit
7a3627f153
1 changed files with 47 additions and 4 deletions
|
|
@ -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<PathBuf>` containing paths to all discovered PDF files
|
||||
pub fn discover_pdf_fixtures<P: AsRef<Path>>(fixtures_path: P) -> Vec<PathBuf> {
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue