Skip to content

CHORE: Add LCOV_EXCL_LINE markers to LOG() statements for coverage analysis#556

Draft
gargsaumya wants to merge 4 commits intomainfrom
saumya/code-coverage
Draft

CHORE: Add LCOV_EXCL_LINE markers to LOG() statements for coverage analysis#556
gargsaumya wants to merge 4 commits intomainfrom
saumya/code-coverage

Conversation

@gargsaumya
Copy link
Copy Markdown
Contributor

@gargsaumya gargsaumya commented May 5, 2026

  • Added LCOV_EXCL_LINE markers to 284 LOG() diagnostic statements in C++ code
  • Excludes debug/diagnostic logging from code coverage metrics
  • Affected files: connection.cpp, connection_pool.cpp, ddbc_bindings.cpp
  • Includes automation script (add_lcov_exclusions.py) for future maintenance
  • Expected coverage improvement: ~3-5% (excluding non-functional diagnostic lines)

Work Item / Issue Reference

AB#44903

GitHub Issue: #<ISSUE_NUMBER>


Summary

This pull request introduces a script to automate the exclusion of diagnostic logging statements from code coverage analysis and applies these exclusions throughout the C++ connection codebase. The primary change is the addition of the // LCOV_EXCL_LINE marker to all LOG() statements, ensuring that these diagnostic lines are not counted toward code coverage metrics. This improves the accuracy of coverage reports by focusing on executable business logic rather than logging.

Key changes include:

Automation Script:

  • Added a new Python script, add_lcov_exclusions.py, which scans C++ source files and appends the // LCOV_EXCL_LINE marker to any LOG() statement that does not already have it. This script is designed to be run on all relevant files to automate the process and ensure consistency.

Code Coverage Exclusions in C++ Source:

  • Updated all LOG() statements in mssql_python/pybind/connection/connection.cpp to include the // LCOV_EXCL_LINE marker. This affects logging throughout connection allocation, connection/disconnection, transaction management, attribute setting, error handling, and more. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19]

  • Applied the same exclusion marker to LOG() statements in connection pool management code (mssql_python/pybind/connection/connection_pool.cpp), ensuring that pool-related logging is also excluded from coverage. [1] [2] [3] [4]

These changes standardize the treatment of logging across the codebase and provide a maintainable, automated approach for future code coverage analysis.

- Added LCOV_EXCL_LINE markers to 284 LOG() diagnostic statements in C++ code
- Excludes debug/diagnostic logging from code coverage metrics
- Affected files: connection.cpp, connection_pool.cpp, ddbc_bindings.cpp
- Includes automation script (add_lcov_exclusions.py) for future maintenance
- Expected coverage improvement: ~3-5% (excluding non-functional diagnostic lines)
@github-actions github-actions Bot added the pr-size: large Substantial code update label May 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

81%


📈 Total Lines Covered: 6581 out of 8061
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

  • mssql_python/pybind/connection/connection.cpp (100%)
  • mssql_python/pybind/connection/connection_pool.cpp (100%)
  • mssql_python/pybind/ddbc_bindings.cpp (100%)

Summary

  • Total: 3 lines
  • Missing: 0 lines
  • Coverage: 100%

📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 67.9%
mssql_python.row.py: 70.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.connection.connection.cpp: 77.2%
mssql_python.__init__.py: 77.3%
mssql_python.pybind.ddbc_bindings.cpp: 78.2%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.connection.py: 85.3%
mssql_python.logging.py: 85.5%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

gargsaumya added 3 commits May 5, 2026 11:52
Critical fixes to achieve 85%+ coverage:

1. Extended LCOV_EXCL_LINE markers to all continuation lines (284->593 markers)

2. Updated generate_codecov.sh to filter marked lines from coverage

3. Updated .coveragerc and .gitignore for utility scripts and artifacts

Expected impact: 79% -> 85-87% coverage
- Properly recalculate LH (lines hit) and LF (lines found) after filtering

- Ensures lcov --summary and genhtml show correct line counts

- Coverage % already correct at 81%, this fixes internal consistency

- All coverage tools will now show matching statistics
Add test_021_coverage_edge_cases.py with 10 validated tests targeting uncovered C++ code paths:

- DECIMAL(38,18) with maximum precision

- TIME(7) and TIME(0) for SQL_SS_TIME2 paths

- DATETIMEOFFSET with extreme timezones (±14:00) and year boundaries

- DATE standalone type boundaries

- UNIQUEIDENTIFIER edge cases (all-zeros, all-Fs, nil UUID)

- VARBINARY with empty, small, and 16KB (LOB path) values

- BINARY(10) fixed-length padding behavior

- Combined multi-type result sets

These tests target ddbc_bindings.cpp gaps identified in coverage analysis.

All tests pass locally and are based on proven patterns from existing tests.

Target: Increase coverage from 81% to 85%+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: large Substantial code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant