Skip to content

Fix: handle empty/zero-line classes in Cobertura parser + add regression tests#177

Merged
afinetooth merged 13 commits intomasterfrom
fix-cobertura-empty-line-overflow
Sep 18, 2025
Merged

Fix: handle empty/zero-line classes in Cobertura parser + add regression tests#177
afinetooth merged 13 commits intomasterfrom
fix-cobertura-empty-line-overflow

Conversation

@afinetooth
Copy link
Member

What this does

  • Fixes a crash in the Cobertura parser (Arithmetic overflow) when a file has:

    • No entries at all, or
    • Only line="0" entries (example: <package>/__init__.py inside customer’s coverage XML).
  • Adds two tiny fixtures (cobertura-empty-lines.xml, cobertura-zero-only.xml) and specs to permanently guard against regressions.

  • Updates developer setup to make Python-based parsers reproducible:

    • Adds .venv/ workflow for Python dependencies (coverage.py + pytest).
    • Pins Python version via .python-version (3.12.7).
    • Updates README with clear local dev/test instructions.
    • Integrates make test with venv so local test runs are reliable.

Why

  • A customer hit the overflow when uploading a large Cobertura XML; parser failed at (1..0) range.
  • This ensures coverage parsing is stable for edge cases and reduces support risk.
  • The developer environment was previously fragile around Python deps; now it’s simple and reproducible.

Testing

  • Added new fixtures under spec/fixtures/cobertura/.
  • Extended cobertura_parser_spec.cr to assert parsing succeeds on those fixtures.
  • Full suite: ✅ 123 examples, 0 failures.

Release note

Fixes Cobertura parser overflow for empty/zero-line classes, adds regression tests, and improves developer setup. Safe to cut a new release after merge.

…ion tests

- Fixed Cobertura parser crash ("Arithmetic overflow") when a file had no <line> entries or only line="0" entries (e.g. kvstore/__init__.py).

- Added two tiny fixtures (cobertura-empty-lines.xml, cobertura-zero-only.xml) and new specs to prevent regressions.

- Updated developer setup:

  • Added .venv/ workflow for Python deps (coverage.py + pytest).

  • Pinned Python version in .python-version (3.12.7).

  • Updated README with clear local dev/test instructions.

  • Added Makefile `test` target integration so `make test` runs with venv.

This fixes the overflow reported by customer large Cobertura XML uploads, adds safety tests, and makes the dev environment reproducible.
…rom the default repos. That’s why CI can’t find it. Another option is to drop back to Ubuntu 22.04.
@coveralls-official
Copy link

coveralls-official bot commented Sep 17, 2025

Pull Request Test Coverage Report for Build rc-aarch64-17813643176

Details

  • 13 of 15 (86.67%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-3.4%) to 90.633%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/coverage_reporter/parsers/cobertura_parser.cr 8 10 80.0%
Totals Coverage Status
Change from base Build 12017105939: -3.4%
Covered Lines: 1340
Relevant Lines: 1457

💛 - Coveralls

@afinetooth afinetooth merged commit e93b5be into master Sep 18, 2025
12 checks passed
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.

1 participant