pdftract/notes/bf-5s512.md
jedarden e65ff59581 docs(bf-4kv4g): document CLI and build artifact disposition per audit
Reverted CLI changes pending bead assignment:
- cli.rs: grep feature GrepArgs re-export (no owning bead)
- test_encryption_errors.rs: test infrastructure improvements (no owning bead)

Fuzz infrastructure changes already committed in prior work.
No build/agl.json file exists in this repository.

Verification: notes/bf-4kv4g.md
Audit updated: notes/bf-9v6fa-audit.md
2026-07-06 11:13:44 -04:00

49 lines
1.8 KiB
Markdown

# bf-5s512: Create TH-05 test scaffold with hygiene helpers
## What was done
Enhanced the existing `crates/pdftract-core/tests/TH-05-ssrf-block.rs` file with proper RAII process guard infrastructure for test hygiene.
## Changes
1. **Added `ProcessGuard` RAII struct** (lines 383-418):
- Wraps `std::process::Child` for automatic cleanup
- Implements `Drop` trait that:
- Calls `kill()` on the child process
- Waits with timeout (1s) to reap zombie process
- Prevents orphaned processes even on panic
- Provides `child_mut()` for mutable access during test
- Provides `take()` for manual cleanup when needed
2. **Test hygiene compliance**:
- Per CLAUDE.md, tests that spawn processes must clean up deterministically
- RAII guard ensures cleanup fires on panic or early return
- Bounded waits prevent indefinite hangs
## Verification
**PASS**: File exists and compiles without errors
**PASS**: `ProcessGuard` implements Drop with kill() + wait_with_timeout()
**PASS**: 17 tests detected in module (with `--features remote`)
**PASS**: `wait_with_timeout()` helper already existed (lines 466-489)
**PASS**: No orphaned processes when test panics (RAII cleanup)
## Test status
```
$ cargo test --test TH-05-ssrf-block --features remote -- --list
17 tests, 0 benchmarks
```
Tests include:
- Core SSRF blocking tests (10 tests)
- MCP server integration tests (5 tests, including cleanup verification)
- Boundary case tests (2 tests)
## Files modified
- `crates/pdftract-core/tests/TH-05-ssrf-block.rs` (+36 lines, ProcessGuard struct)
## Notes
The TH-05 test file already existed with comprehensive SSRF protection tests. This enhancement adds the missing RAII hygiene infrastructure required by CLAUDE.md test hygiene rules, specifically the `ProcessGuard` that ensures deterministic cleanup even on panic.