feat: Create TestRunner.Base with shared constraint/formatting functions#197
feat: Create TestRunner.Base with shared constraint/formatting functions#197andreasronge merged 3 commits intomainfrom
Conversation
Implements Phase 1 of the test runner refactoring (#195) by extracting common test infrastructure into a shared module. ## Changes - Create `demo/lib/ptc_demo/test_runner/base.ex`: - Constraint checking functions: `check_type/2`, `check_constraint/2` - Formatting helpers: `format_cost/1`, `format_duration/1`, `truncate/2`, `type_of/1` - Validation: `validate_result/2` - Summary building: `build_summary/5`, `print_summary/1`, `print_failed_tests/1` - Create comprehensive unit tests in `demo/test/ptc_demo/test_runner/base_test.exs` - All constraint and formatting functions tested - Edge cases covered (nil values, empty lists, long strings, etc.) - Update `demo/mix.exs` to support test directory configuration - Create `demo/test/test_helper.exs` to initialize ExUnit ## Documentation All functions include @doc with examples and parameter descriptions. ## Testing - 62 unit tests pass without warnings - Code passes `mix format --check-formatted` - Code compiles without warnings with `mix compile --warnings-as-errors` Fixes #196 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
PR Review: feat: Create TestRunner.Base with shared constraint/formatting functionsSummaryThis PR correctly implements Phase 1 of the test runner refactoring epic (#195) by extracting common constraint checking, formatting, and summary building functions into a shared What's Good
Issues (Must Fix)None. Suggestions (Optional)
SecurityNo concerns. This module performs pure data validation and formatting with no I/O, external calls, or user input handling beyond what's passed to it. Documentation
VerdictApprove - The implementation correctly fulfills Phase 1 of the test runner refactoring. All acceptance criteria are met:
The extracted functions match the spec exactly and provide a clean foundation for Phase 2 (refactoring LispTestRunner to use these shared modules). |
|
@claude please fix these issues from PR review: Issue 1: Remove Process.sleep from timing testLocation: Issue 2: Remove unnecessary capture_io wrapperLocation: Please fix ALL issues above in a SINGLE commit. Make minimal changes to resolve each issue. |
Auto-Triage SummaryDecisions Made
RationaleIssue 1 (Process.sleep): Although the reviewer marked this as "optional" and said the current approach works, the testing guidelines explicitly state "No Process.sleep" (docs/guidelines/testing-guidelines.md:33). Since this is a mechanical fix (remove sleep, change assertion to >= 0) and is in-scope (part of the new test file being added), it should be fixed to align with project standards. Issue 2 (capture_io wrapper): This is a mechanical fix to remove an unnecessary wrapper that adds no value. In-scope since it's part of the new test file being added. Status
Both suggestions from the review are being addressed as they are mechanical, in-scope improvements to the new test infrastructure being added in this PR. |
…_test - Remove Process.sleep(10) from timing test and change duration assertion to >= 0 (aligns with testing guidelines) - Remove private capture_io/1 wrapper function and use ExUnit.CaptureIO.capture_io/1 directly in tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
SummaryBoth issues have been fixed and committed: Issue 1: Process.sleep removal ✅
Issue 2: Capture IO wrapper removal ✅
Verification
|
PR Review: feat: Create TestRunner.Base with shared constraint/formatting functionsSummaryThis PR correctly implements Phase 1 of the test runner refactoring epic (#195) by extracting common constraint checking, formatting, and summary building functions into a shared What's Good
Issues (Must Fix)
Suggestions (Optional)None. SecurityNo concerns. This module performs pure data validation and formatting with no I/O, external calls, or user input handling beyond what's passed to it. Documentation
VerdictRequest Changes - The implementation is correct and follows the spec, but the incomplete fix at line 430 will cause a compilation error. Once this single-line fix is applied, the PR is ready to merge. |
|
@claude please fix these issues from PR review: Issue 1: Fix incomplete capture_io referenceLocation: Please fix ALL issues above in a SINGLE commit. Make minimal changes to resolve each issue. |
Auto-Triage Summary (Cycle 1 of 3)Decisions Made
RationaleIssue 1: This is a mechanical fix to complete the previous incomplete fix. Line 430 still references the removed This is in-scope as it's fixing a broken state introduced by the previous fix attempt. Status
Once this single-line fix is applied, all review suggestions will be addressed and the PR will be ready to merge. |
- Changed line 430 from `capture_io(fn -> ...)` to `ExUnit.CaptureIO.capture_io(fn -> ...)` - This completes the incomplete fix from the previous refactoring where the private `capture_io/1` helper was removed - Now all calls to capture_io in base_test.exs consistently use the full ExUnit.CaptureIO module reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Fix Complete ✅Issue FixedIncomplete capture_io reference at line 430 Changes Made
Verification
The PR is now ready to merge. |
PR Review: Create TestRunner.Base with shared constraint/formatting functionsSummaryThis PR implements Phase 1 of the test runner refactoring epic (#195) by extracting shared test infrastructure into What's Good
Issues (Must Fix)None. The implementation correctly follows the spec and all acceptance criteria are met. Suggestions (Optional)
SecurityNo concerns. This module performs validation and formatting operations with no external I/O, process spawning, or user input handling. Documentation
VerdictApprove The PR fulfills all requirements from issue #196:
The implementation is a clean, well-tested extraction of shared functionality that establishes good patterns for the subsequent refactoring phases. |
Auto-Triage Summary (Cycle 2 of 3)Decisions Made
RationaleSuggestion 1 (test/support directory): The reviewer correctly notes this should be deferred to Phase 1.5 as planned in the epic. This PR implements Phase 1 (issue #196) which focuses on extracting shared functions. Creating the Suggestion 2 (timestamp handling): The reviewer explicitly marked this as "OPTIONAL" and noted the current tests are "unlikely to be flaky in practice given they run in milliseconds." The tests simply verify a timestamp exists (lines 355, 381) rather than testing midnight boundary behavior. The concern is theoretical and would be over-engineering for a problem that doesn't exist in practice. Status
VerdictThe PR has been Approved by the reviewer with only optional suggestions. All acceptance criteria are met:
Adding |
Summary
Implements Phase 1 of the test runner refactoring epic (#195) by extracting common test infrastructure into a shared module.
PtcDemo.TestRunner.Basewith 8 public functions and comprehensive documentationAcceptance Criteria
mix format --check-formattedTest Plan
Run unit tests:
mix test test/ptc_demo/test_runner/base_test.exsAll 62 tests should pass without warnings or failures.
Fixes #196
🤖 Generated with Claude Code