pdftract/notes/bf-394lb.md
jedarden ace8c2a26c test(bf-394lb): implement basic test skeleton calling pdftract extract
- Add test_extract_all_discovered_pdfs() function to forms_integration.rs
- Use walkdir-based discover_pdf_fixtures() for recursive PDF discovery
- Spawn pdftract extract --json process for each PDF and capture output
- Print detailed status and output preview for debugging
- Fix pdftract_bin() path resolution (workspace target dir)

Closes bf-394lb. Verification: notes/bf-394lb.md. Tests: PASS (compiles, runs, no hangs).
2026-07-05 15:27:27 -04:00

1.7 KiB

bf-394lb Verification Note

Summary

Implemented basic test skeleton test_extract_all_discovered_pdfs that calls pdftract extract --json on discovered PDF fixtures.

Implementation

  • Added test_extract_all_discovered_pdfs() function to tests/forms_integration.rs
  • Test uses the walkdir-based discover_pdf_fixtures() helper for recursive PDF discovery
  • For each PDF, spawns pdftract extract --json <file> and captures stdout/stderr
  • Prints detailed status and output preview for each processed file
  • Counts and reports success/failure summary

Bug Fix

Fixed path resolution bug in pdftract_bin() helper:

  • Changed from ../target/debug/pdftract to ../../target/debug/pdftract
  • Binary lives in workspace target directory, not relative to crate directory
  • Path: crates/pdftract-cli/../../target/debug//home/coding/pdftract/target/debug/

Testing

cargo test --package pdftract-cli --test forms_integration test_extract_all_discovered_pdfs -- --nocapture

Result: PASS

  • Test compiled and ran successfully
  • No hangs or panics
  • Gracefully handles empty fixtures directory
  • Ready to process PDF fixtures when they are added

Acceptance Criteria Status

  • Test function exists and compiles
  • Test calls pdftract extract for each discovered fixture
  • Test runs via cargo test forms_integration
  • No test hangs or panics
  • May have failures (PDF extraction errors) - that's OK for this step

Files Modified

  • crates/pdftract-cli/tests/forms_integration.rs (added test function, fixed pdftract_bin path)

Commit

Commit will be made with:

test(bf-394lb): implement basic test skeleton calling pdftract extract