-
Notifications
You must be signed in to change notification settings - Fork 10
feat: implement partials_as_hits feature for LCOV parser #383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement partials_as_hits feature for LCOV parser #383
Conversation
This commit adds support for the partials_as_hits configuration option to the LCOV parser, bringing it in line with other coverage parsers (JaCoCo, Cobertura, Go). ## Changes Made ### Core Implementation - **lcov.py**: Added partials_as_hits configuration reading and conversion logic - **_process_file()**: Updated to accept partials_as_hits parameter - **Branch processing**: Convert partial coverage (e.g., '1/2') to hits (1) when enabled ### Configuration Schema - **user_schema.py**: Added LCOV parser configuration validation - Supports: parsers.lcov.partials_as_hits (boolean, default: false) ### Test Coverage - **test_lcov.py**: Added comprehensive test cases: - test_lcov_partials_as_hits_enabled(): Tests conversion of partials to hits - test_lcov_partials_as_hits_disabled(): Tests default behavior preservation - test_lcov_partials_as_hits_mixed_coverage(): Tests mixed scenarios - **test_validation.py**: Added schema validation tests ### Documentation - **LCOV_PARTIALS_AS_HITS.md**: Comprehensive feature documentation including: - Implementation details and logic - Usage examples and migration guide - Consistency with other parsers - Test coverage overview ## Behavior ### With partials_as_hits: true - '1/2' partial coverage → 1 (hit) - '2/3' partial coverage → 1 (hit) - '2/2' full hit → '2/2' (unchanged) - '0/2' miss → '0/2' (unchanged) ### With partials_as_hits: false (default) - All coverage types remain unchanged (backward compatible) ## Configuration Example ## Implementation Details - Follows established patterns from JaCoCo, Cobertura, and Go parsers - Minimal performance impact (single boolean check per branch line) - Comprehensive test coverage with realistic LCOV data - Backward compatible (defaults to false) Closes: #[issue-number] (if applicable) Co-authored-by: TDD Implementation Process
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #383 +/- ##
==========================================
- Coverage 94.19% 93.85% -0.34%
==========================================
Files 1254 1284 +30
Lines 46238 46450 +212
Branches 1455 1522 +67
==========================================
+ Hits 43554 43597 +43
- Misses 2379 2543 +164
- Partials 305 310 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #383 will not alter performanceComparing Summary
|
Critical bug fix addressing incorrect branch counting when partials_as_hits is enabled. ## Problem When partials_as_hits was enabled, partial branches were converted from: - coverage: '1/2' -> 1 ✅ (correct) - coverage_type: CoverageType.branch -> CoverageType.line ❌ (incorrect) This caused get_line_totals() to exclude converted partials from branch counts since it only counts lines with type='b' (CoverageType.branch maps to 'b'). ## Solution - Keep coverage_type as CoverageType.branch for converted partials - This maintains proper branch counting: line.type = 'b' - Aligns behavior with JaCoCo parser (preserves branch type) - Ensures accurate branch coverage metrics ## Changes - lcov.py: Remove incorrect coverage_type change to CoverageType.line - test_lcov.py: Update test expectations to expect 'b' type for converted partials - LCOV_PARTIALS_AS_HITS.md: Correct documentation ## Verification - Converted partials now maintain branch type for proper counting - Tests updated to reflect correct behavior - Branch coverage metrics will be accurate Fixes: Branch count inconsistency when partials_as_hits enabled Severity: Critical - affects coverage metrics accuracy
Auto-formatting applied by pre-commit hooks to match project style guidelines. The tuple formatting was changed to multi-line format for better readability.
The original tests incorrectly expected both line coverage AND branch coverage to exist as separate entries when both DA: and BRDA: exist for the same line. LCOV parser behavior (confirmed by existing test_regression_partial_branch): - When both DA:10,5 and BRDA:10,0,0,1 exist for line 10 - Branch coverage overwrites line coverage - Result: Only one entry (10, '1/2', 'b', ...) not two separate entries Fixed test expectations to match actual LCOV parser behavior: - test_lcov_partials_as_hits_enabled: Expect only branch entry with hit conversion - test_lcov_partials_as_hits_disabled: Expect only branch entry with partial preserved - test_lcov_partials_as_hits_mixed_coverage: Expect only branch entries This aligns with how the existing LCOV parser works and maintains backward compatibility.
Auto-formatting applied by pre-commit hooks: - Remove trailing whitespace after triple quotes - Multi-line format for long tuple in test_lcov_partials_as_hits_mixed_coverage This prevents CI formatting loops by applying the formatting locally.
- Fix issue where string 'false' would be truthy in YAML config - Add robust boolean casting to handle 'false', 'true', '0', '1', etc. - Add test to verify string 'false' correctly behaves as boolean False - Refactor tests to eliminate duplication using class properties - Move repeated LCOV test data to PARTIAL_BRANCH_LCOV_DATA class property - Add reusable partial_test_path_fixer static method This prevents configuration bugs where users specify boolean values as strings in YAML, ensuring partials_as_hits works correctly regardless of how the boolean is specified in the configuration.
|
Summary for the latest commit ( 🐛 Boolean Type Casting Fix + Test RefactoringLatest Commit Summary:Fix: Boolean Type Casting for LCOV partials_as_hits Configuration🐛 Problem Solved
🔧 Solution Implemented
🧪 Testing Added
🧹 Code Quality Improvements
📁 Files Changed (2)
⚡ ImpactPrevents configuration bugs where users specify boolean values as strings in YAML, ensuring This commit specifically addresses the boolean casting issue @adrianviquez identified and cleans up the test code duplication. |
c0ad006 to
a440c14
Compare
Head branch was pushed to by a user without write access
a440c14 to
083a6ef
Compare
This commit adds support for the partials_as_hits configuration option to the LCOV parser, bringing it in line with other coverage parsers (JaCoCo, Cobertura, Go).
Changes Made
Core Implementation
Configuration Schema
Test Coverage
Documentation
Behavior
With partials_as_hits: true
With partials_as_hits: false (default)
Configuration Example
Implementation Details
Closes: #[issue-number] (if applicable)
Co-authored-by: TDD Implementation Process
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.