Files

38 lines
3.1 KiB
Markdown

# Testing Per-Run Reporters, Subprocess Isolation, and Deterministic Harness
Task ID: M-TESTING-02, M-TESTING-03
Phase: P1
Status: APPROVED
Contracts: C-01, C-04, C-16
## 1. Context and baseline
`Testing` (`Runner.cpp`, `Assert.cpp`, `Config.hpp`, `JUnitReporter.cpp`) currently uses a process-global static `std::ofstream` for JUnit reporting, silently turns malformed regex or empty explicit filter selections into passing 0-test runs, retains unbounded per-test assertions, and lacks owned `FailureCapture`, isolated subprocess test execution, versioned deterministic property shrinking, and clock/order-controlled `DeterministicRun`.
## 2. Deliverables
- Updated `include/Void/Testing/{Config,Assert,Runner}.hpp` and `src/Testing/{Assert,Runner}.cpp`:
- Per-run owned JUnit stream checking open/write health cleanly.
- Strict CLI/config validation (invalid regex, unknown reporter, unopenable output path, empty selection without `--allow-empty` fail with exit code 2).
- Bounded per-test assertion retention (`1000` assertions / `1 MiB` diagnostics) and stray-assertion counter.
- Single-teardown fixture lifecycle recording teardown errors in `cleanup_error` without masking primary test failure.
- `--selftest-child <abort|hang|flood>` fixtures inside `Runner::main`.
- New `include/Void/Testing/Capture.hpp` (`FailureCapture`) and `include/Void/Testing/{Subprocess.hpp}` + `src/Testing/Subprocess.cpp` (`current_executable_path`, `run_isolated_subprocess`, `ProcessTestOptions`, `ProcessOutcome`, `ProcessTestResult`).
- New `include/Void/Testing/Deterministic.hpp` (`ReplayToken`, version-1 rejection-mapped `DeterministicRng`, `check_property` with shrinking & budget-exhaustion `inconclusive`, and `DeterministicRun` schedule/clock/timer harness).
- Tests in `tests/standalone/Testing/{FrameworkHardening,Deterministic}.cpp`.
## 3. Exact files and interfaces
- `include/Void/Testing/{Config,Assert,Runner,Capture,Subprocess,Deterministic}.hpp`
- `src/Testing/{Assert,Runner,Subprocess}.cpp`
- `tests/standalone/Testing/{FrameworkHardening,Deterministic}.cpp`
## 4. Edge cases
- Child process `flood` saturating stdout and stderr concurrently drains via non-blocking `poll` with bounded truncation without pipe deadlock.
- Child process `hang` beyond `ProcessTestOptions::timeout` terminates via `SIGKILL` and reports `ProcessOutcome::timed_out`.
- Child process `abort` reports `ProcessOutcome::crashed` (`SIGABRT`) safely even under ASan/UBSan.
- Property shrinking preserves counterexample failure category and reports `inconclusive` on step, time, or discard exhaustion.
## 5. Acceptance criteria
- `FrameworkHardening*|Deterministic*|Math*|ContainerFixture*|StructRepr*` and full 1,345+ `VoidTests` pass under RelWithDebInfo `-Werror` and ASan+UBSan.
## 6. Verification commands
```sh
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w4b-testing -G Ninja -DVOID_ENABLED_MODULES="Core;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w4b-testing && /tmp/void-w4b-testing/tests/VoidTests --filter "FrameworkHardening*|Deterministic*|Math*|ContainerFixture*|StructRepr*" && ctest --test-dir /tmp/void-w4b-testing --output-on-failure --timeout 60'
```