Skip to content

test: improve Expat.xs code coverage (93% → 95%)#249

Merged
toddr merged 1 commit intomainfrom
koan.toddr.bot/expat-xs-coverage
Apr 9, 2026
Merged

test: improve Expat.xs code coverage (93% → 95%)#249
toddr merged 1 commit intomainfrom
koan.toddr.bot/expat-xs-coverage

Conversation

@toddr-bot
Copy link
Copy Markdown
Collaborator

@toddr-bot toddr-bot commented Apr 9, 2026

What

Adds t/expat_xs_coverage.t with 26 tests targeting previously uncovered code paths in Expat.xs, identified through gcov analysis.

Why

Expat.xs is the core C/XS layer — any regression here is a crash or corruption. Raising line coverage from 93.19% to 94.57% hardens the most critical paths: callback suspend/resume during skip_until(), namespace cleanup in finish(), and external entity handling edge cases.

How

Used --coverage compile flags + gcov to identify 74 uncovered lines, then classified them:

  • Testable (~15 lines): skip_until suspend/resume branches, UnsetAllHandlers NS path, recString append, ExternEnt error/pubid paths → all covered by new tests
  • Unreachable (~59 lines): defensive croaks (corrupted Perl objects), OOM paths (Perl's allocator never returns NULL), platform-specific (XML_CONTEXT_BYTES), boolean sub-expression artifacts

Testing

make test — 680 tests pass. gcov confirms coverage increase.

🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 422 insertions(+)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Adds 26 tests (24 run + 2 platform-skipped) exercising previously
uncovered code paths in Expat.xs identified via gcov analysis.

Key paths covered:
- skip_until() suspend/resume for Char, CData, Comment, Proc,
  Notation, Unparsed, and ExternEnt handlers
- UnsetAllHandlers namespace branch via finish() on NS parser
- recString append path (multi-attribute start tags)
- RecognizedString recstring reset across multiple calls
- skip_until early return (index <= st_serial)
- ExternalEntityRef with PUBLIC id
- pe_implicit DefaultCurrent for PE references
- Do_External_Parse string return branch
- ExternEnt error path (malformed XML from handler)

Moves Expat.xs line coverage from 93.19% to 94.57%.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@toddr toddr marked this pull request as ready for review April 9, 2026 22:07
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.73%. Comparing base (4aa049b) to head (d191901).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #249      +/-   ##
==========================================
+ Coverage   72.71%   75.73%   +3.02%     
==========================================
  Files           1        1              
  Lines        1092     1092              
  Branches      342      342              
==========================================
+ Hits          794      827      +33     
+ Misses         74       59      -15     
+ Partials      224      206      -18     
Flag Coverage Δ
perl 75.73% <ø> (+3.02%) ⬆️
xs 75.73% <ø> (+3.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@toddr toddr merged commit 853e6cf into main Apr 9, 2026
36 checks passed
@toddr toddr deleted the koan.toddr.bot/expat-xs-coverage branch April 9, 2026 22:09
toddr-bot added a commit that referenced this pull request Apr 15, 2026
The following test files were added in recent PRs but not included in
MANIFEST, meaning they would be absent from the CPAN distribution tarball:

- t/coverage_gaps.t (PR #248)
- t/expat_xs_coverage.t (PR #249)
- t/parser_api.t (PR #244)
- t/stream_delimiter.t (PR #243)

Also extend MANIFEST.SKIP with standard exclusions for build artifacts
(blib/, *.o, *.so, *.bs, *.c), coverage data (cover_db/), and OS files
(.DS_Store) to prevent future regenerations from picking up stale files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants