Skip to content

feat: surface failing test name inline + simplify reporter internals#14

Merged
Fahl-Design merged 8 commits into
mainfrom
feat/extend_report
May 12, 2026
Merged

feat: surface failing test name inline + simplify reporter internals#14
Fahl-Design merged 8 commits into
mainfrom
feat/extend_report

Conversation

@Fahl-Design

@Fahl-Design Fahl-Design commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Print Test failed: <full_name> inside the inline AI Context block so failures are scannable without opening the JSON/text report.
  • Extend unit coverage for the inline-context path (failure/error/warning/disabled/non-failure statuses + end-to-end JSON+text writing).
  • Round of low-risk simplifications: extract printSection helper, drop redundant array_values wrap, nullsafe suite name, collapse normalizeArtifacts, fold opposing isNoiseFrame branches, mark PathNormalizer roots readonly, replace six near-identical validation blocks in ReporterConfig::fromArray with readEnum/readOutput/readPositiveInt/readBool helpers (and drop the @phpstan-ignore-next-line suppressions).
  • Test plumbing: shared PathNormalizerFactory fixture; data-driven testInvalidConfigThrows.
  • Harden two edges flagged by CodeRabbit: guard ReflectionClass::getFileName() in makeStubTest; preserve resolved path when rtrim would empty a root $outputDir.
  • Drift bump: .php-version 8.3.30 → 8.3.31, phpunit 12.5.23 → 12.5.24.

Test plan

  • composer test — 38 tests / 113 assertions
  • composer stan — clean (no errors at level: max)
  • composer cs:check — clean
  • coderabbit review --agent -t all --base main — 0 findings after fixes
  • Manual: vendor/bin/codecept run --report and inspect tests/_output/ai-report.{json,txt} shape unchanged for a real failing suite

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Summary by CodeRabbit

Release Notes

  • Chores

    • Updated PHP version to 8.3.31
  • Tests

    • Added new test fixtures to support reporter testing
    • Expanded test coverage for AI reporter functionality and failure context rendering
    • Refactored test structure for improved consistency and maintainability

Review Change Stack

Add `Test failed: <full_name>` line to inline AI Context output so
report consumers see which test produced the captured failure.

Extend unit coverage for inline-context printing across failure/error/
warning statuses, the disabled `report` option, non-failure statuses,
and end-to-end report writing.
Drop redundant array_values() wrap on HintGenerator output (already a
list), nullsafe the suite-name extraction, collapse normalizeArtifacts
into a single ternary, and extract a printSection() helper to remove
the repeated section-printing boilerplate in printInlineContext().
Replace six near-identical type/value checks with three private
helpers (readEnum, readPositiveInt, readBool) plus one dedicated
readOutput that falls back to the supplied default on null/empty.
The helpers narrow `mixed` cleanly, so the @phpstan-ignore-next-line
suppressions are no longer needed.
Add tests/Support/Fixture/PathNormalizerFactory to replace three
ad-hoc constructions of PathNormalizer across the report and trace
test files.

Collapse the two single-case `testInvalidFormatThrows` /
`testInvalidMaxFramesThrows` methods into a data-driven
`testInvalidConfigThrows` and extend coverage to the bool / output /
non-int cases exercised by the new ReporterConfig validator helpers.
ReporterConfig::fromArray previously rtrim-ed the resolved output
directory, which could collapse a root path (e.g. "/") into an empty
string and violate the @var non-empty-string contract. Keep the
trimmed value only when it is still non-empty; otherwise fall back to
the resolved path.

AiReporterTest::makeStubTest cast ReflectionClass::getFileName()
straight to string. Guard with assertNotFalse so a future internal
class swap fails loudly instead of silently passing an empty filename.
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40655261-a841-460b-b62b-d2ec788138be

📥 Commits

Reviewing files that changed from the base of the PR and between d6cbcbd and b6d2891.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • .php-version
  • src/Config/ReporterConfig.php
  • src/Extension/AiReporter.php
  • src/Report/PathNormalizer.php
  • src/Util/TraceFrameProcessor.php
  • tests/Support/Fixture/CapturingOutput.php
  • tests/Support/Fixture/PathNormalizerFactory.php
  • tests/Support/Fixture/StubTest.php
  • tests/Unit/Config/ReporterConfigTest.php
  • tests/Unit/Extension/AiReporterTest.php
  • tests/Unit/Report/PathNormalizerTest.php
  • tests/Unit/Report/TraceNormalizerTest.php
  • tests/Unit/Util/TraceFrameProcessorTest.php

📝 Walkthrough

Walkthrough

This PR refactors configuration validation and reporter output rendering while introducing reusable test fixtures. It updates three core classes with simplifications and immutability constraints, then consolidates test infrastructure to reduce duplication and improve maintainability.

Changes

Core Refactoring and Test Infrastructure

Layer / File(s) Summary
Test support fixtures
tests/Support/Fixture/CapturingOutput.php, tests/Support/Fixture/PathNormalizerFactory.php, tests/Support/Fixture/StubTest.php
New test fixtures provide console output capture, centralized path normalizer construction with default arguments, and a minimal Test subclass for event-driven unit tests.
Config validation refactoring and testing
src/Config/ReporterConfig.php, tests/Unit/Config/ReporterConfigTest.php
ReporterConfig::fromArray() delegates parsing and validation to new private helper methods with standardized InvalidArgumentException handling; test suite consolidates multiple invalid-input cases into a single parameterized test.
Path normalization immutability and test consolidation
src/Report/PathNormalizer.php, tests/Unit/Report/PathNormalizerTest.php
PathNormalizer root path fields become immutable via readonly; test setup is unified to construct normalizers through the new factory instead of direct instantiation.
Trace frame simplification and test updates
src/Util/TraceFrameProcessor.php, tests/Unit/Util/TraceFrameProcessorTest.php, tests/Unit/Report/TraceNormalizerTest.php
TraceFrameProcessor::isNoiseFrame() consolidates conditional branches into a single early-return; all dependent tests switch to factory-based normalizer construction.
Reporter inline context rendering and output tests
src/Extension/AiReporter.php, tests/Unit/Extension/AiReporterTest.php
AiReporter centralizes inline context rendering through a new printSection() helper, removes array normalization of hints, and simplifies artifact handling; test suite expands with comprehensive coverage of failure event output, report writing, and suppression scenarios.
PHP version update
.php-version
Updates PHP runtime version from 8.3.30 to 8.3.31.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 Config helpers hop and play,
Test fixtures guide the way,
Output renders clean and bright,
Immutable fields set just right,
Refactored code hops into the night! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: surface failing test name inline + simplify reporter internals' accurately summarizes the main changes: adding inline test failure display and refactoring reporter code.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/extend_report

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Fahl-Design Fahl-Design self-assigned this May 12, 2026
@Fahl-Design Fahl-Design merged commit ec008d9 into main May 12, 2026
7 checks passed
@Fahl-Design Fahl-Design deleted the feat/extend_report branch May 12, 2026 20:30
webproject-bot Bot pushed a commit that referenced this pull request May 12, 2026
## [1.2.0](1.1.1...1.2.0) (2026-05-12)

### Features

* **docs:** sync README inline AI Context example with actual output ([e6f5d5f](e6f5d5f))
* **refactor:** refactor and simplify reporter internals ([#14](#14)) ([ec008d9](ec008d9))
@webproject-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant