Skip to content

Test Coverage Goal - March 2026 - Target: 52% (Python bootstrap layer) #898

@github-actions

Description

@github-actions

📊 Test Coverage Status Report

Analysis Date: 2026-03-23
Current Coverage: Effectively 0% on Python layer (no Python test files exist)
Target for Month: Add meaningful test coverage to the Python bootstrap layer


🔍 Coverage Reality Check

The test-coverage-improver workflow references a 44% coverage figure, but a codebase audit reveals important context:

Layer Status
Rust (primary) 242 source files, 19,366+ lines of tests — Rust CI runs cargo test --all
Python bootstrap 2 source files (247 lines) — zero test files exist
Coverage tooling No .coveragerc, no coverage.xml, no pytest configured

The 44% figure likely reflects Rust test coverage (via cargo test) rather than Python pytest coverage. The Python layer has 0% measurable coverage because no Python tests run in CI.


🎯 Priority Test Targets for March 2026

src/azlin/rust_bridge.py (225 lines — 0% covered)

This is the critical Python entry point. It has complex logic for finding/installing the Rust binary:

Function Lines Complexity Priority
_platform_suffix() 16 Low 🟡 Medium
_is_rust_binary() 11 Low 🟡 Medium
_find_rust_binary() 15 Medium 🔴 Critical
_download_from_release() 68 High 🔴 Critical
_build_from_source() 27 Medium 🔴 Critical
_exec_rust() 7 Low 🟡 Medium
entry() 32 Medium 🔴 Critical

Note: PR #885 adds tests/unit/test_rust_bridge.py with 7 tests — this is the right foundation! Merge it to start coverage tracking.

src/azlin/__init__.py (22 lines — trivial, MI score 100)

Simple package metadata — low priority, but easy wins for coverage percentage.


📋 March 2026 Testing Checklist

Foundation Setup (prerequisite)

  • Merge PR fix(security): harden tar extraction in rust_bridge against path traversal (#876) #885 (adds tests/unit/test_rust_bridge.py — 7 tests)
  • Add pytest + pytest-cov to [dependency-groups].dev in pyproject.toml
  • Add coverage configuration to pyproject.toml:
    [tool.coverage.run]
    source = ["src/azlin"]
    branch = true
    
    [tool.coverage.report]
    exclude_lines = ["if __name__ == .__main__.", "pragma: no cover"]
  • Update rust-ci.yml or ci.yml to run Python tests with coverage:
    - name: Python tests
      run: python -m pytest tests/unit/ --cov=src/azlin --cov-report=xml

High-Priority Tests (rust_bridge.py)

  • _platform_suffix(): Test all 5 platform/arch combinations (linux x86_64, linux aarch64, macOS x86_64, macOS arm64, Windows, unknown)
  • _find_rust_binary(): Test found-at-each-candidate-path, none-found, non-executable skipped
  • _download_from_release(): Test download success, API failure, no matching asset, extraction error
  • _build_from_source(): Test cargo-not-found, cargo-success, cargo-failure
  • entry(): Test full bootstrap flow (found, download, build, all-fail)

Medium-Priority Tests

  • _is_rust_binary(): Test subprocess success/failure/timeout
  • _exec_rust(): Test Windows path (subprocess) vs Unix path (execvp)

🛠️ Testing Approach

All external calls must be mocked (no real network/filesystem):

# Example: Test platform detection
from unittest.mock import patch
from azlin.rust_bridge import _platform_suffix

def test_platform_suffix_linux_x86_64():
    with patch("platform.system", return_value="Linux"), \
         patch("platform.machine", return_value="x86_64"):
        assert _platform_suffix() == "linux-x86_64"

def test_platform_suffix_unknown_returns_none():
    with patch("platform.system", return_value="FreeBSD"), \
         patch("platform.machine", return_value="x86_64"):
        assert _platform_suffix() is None
# Example: Test binary discovery
from unittest.mock import patch, MagicMock
from azlin.rust_bridge import _find_rust_binary

def test_find_binary_returns_managed_path_when_valid(tmp_path):
    fake_bin = tmp_path / "azlin"
    fake_bin.touch()
    with patch("azlin.rust_bridge.MANAGED_BIN", fake_bin), \
         patch("os.access", return_value=True), \
         patch("azlin.rust_bridge._is_rust_binary", return_value=True):
        result = _find_rust_binary()
        assert result == str(fake_bin)

📈 Coverage Progress Tracker

Week Coverage % Tests Added Notes
2026-03-23 ~0% (baseline) 0 No Python tests in CI
Target end of March 52%+ 15–20 Bootstrap layer covered

🔗 Related


Next Month Preview

Once the Python bootstrap is covered, consider adding Rust coverage reporting via cargo-tarpaulin or cargo-llvm-cov to track the actual coverage of the primary codebase. The 19,366+ lines of Rust tests deserve visibility in coverage metrics too.

Generated by Test Coverage Improvement Tracker

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions