Skip to main content

sundgren

Sundgren is Swedish for "sound branch". Given a repo, a base ref and a patch (usually one that changes tests), it answers: what happened to source coverage because of this patch?

It runs a coverage command on the base tree and on the patched tree (git worktrees), diffs the two lcov files with line numbers mapped through the patch, and writes a JSON report (sundgren.delta/1) or a text summary.

Install

uv tool install sundgren      # or: pipx install sundgren

Sundgren never imports coverage or pytest itself. They run as commands in your project's environment: {python} is the python on your PATH (or python3), override with --python.

Python

sundgren run --patch skip_divide.patch                 # preset "pytest" is picked from pyproject.toml
sundgren run --patch p.patch --base main --format text

The pytest preset runs coverage run --branch -m pytest <selected tests> then coverage lcov. It only runs the test files the patch touches; if the patch touches conftest.py, any other .py file or pytest config, it runs everything. Override with --tests tests/test_x.py ....

  • Set [run] source = <your package> in .coveragerc, so never-imported files are reported.
  • Editable installs measure your main checkout, not the worktree. Sundgren detects this and exits 1; fix with --env PYTHONPATH={worktree}/src.

Rust

sundgren run --patch ignore_divide.patch                          # cargo-llvm-cov
sundgren run --patch ignore_divide.patch --preset cargo-tarpaulin
sundgren run --patch p.patch --tests divide                       # name filters, passed after --

Each run uses its own CARGO_TARGET_DIR, so both sides build from scratch. Function names are stored mangled.

Any language: --cmd

Anything that writes lcov works:

sundgren run --patch p.patch \
  --cmd "npx jest --coverage --coverageReporters=lcov --coverageDirectory={out}" \
  --lcov "{out}/lcov.info"

Placeholders: {python}, {out} (per-run output dir), {worktree}, {lcov}, {junit}, {tests}. A token that is exactly {tests} expands to one argv entry per selected test (none if nothing is selected). --shell runs commands through /bin/sh -c. --junit TEMPLATE adds test outcomes to the report. --env K=V sets (templated) environment variables.

Custom presets go in sundgren.toml ([presets.<name>]) or [tool.sundgren.presets.<name>] in pyproject.toml, with the same keys as src/sundgren/lang/python/presets.toml. sundgren presets lists them.

Other commands

sundgren diff base.lcov patched.lcov --patch p.patch --base-root A --patched-root B
sundgren ingest coverage.lcov --root .        # normalized snapshot as JSON

Options shared by run and diff: --format json|text, -o OUT, --full (include unchanged lines, functions and tests), --counts (hit-count changes on lines that stayed hit), --repeat N (run only; lines whose status varies across runs are reported as flaky).

Exit codes: 0 ok, 1 tool or run failure, 2 usage error, 3 patch doesn't apply.

Report

files[].lines[].category is one of lost, gained, new_hit, new_miss, deleted_hit, deleted_miss, kept_hit, kept_miss, unmeasured (genhtml: LBC, GBC, GNC, UNC, DCB, DUB, CBC, UBC). Functions are went_dark, lit_up, partial_loss, partial_gain, mixed, unchanged, added or removed. tree rolls the line stats up per directory. Schema: src/sundgren/core/report/delta.schema.json.

Development

uv sync                       # dev env in .venv
uv run pytest
uv run ruff check . && uv run ruff format --check .
uv run mypy

Layers: core (no languages, no subprocesses) ← run (worktrees, command templates) ← lang (presets, selectors, symbolizers). Only cli.py imports lang. tests/unit/test_layering.py enforces this. See DECISIONS.md for choices the spec left open.

License

Apache-2.0. See LICENSE.

Metadata

Release files for sundgren 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sundgren 0.1.0
File Size Uploaded Provenance Actions
sundgren-0.1.0.tar.gz 150.5 kB With provenance Details for sundgren-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sundgren 0.1.0
File Interpreter ABI Platform Actions
sundgren-0.1.0-py3-none-any.whl Python 3 none any Details for sundgren-0.1.0-py3-none-any.whl

Total release size: 205.7 kB

Release files / sundgren-0.1.0.tar.gz

Download URL sundgren-0.1.0.tar.gz
Size 150.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d483cf3ca86d3f6cbc5d9c5ec56c0be888efcb3f2e8007a4788793c71435d655
BLAKE2b-256 checksum
How to use checksums
c30630c72ff6371e465165a70cc3969c2e0dbc9cfc6ac5bd1287f6e92eaadaea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / sundgren-0.1.0-py3-none-any.whl

Download URL sundgren-0.1.0-py3-none-any.whl
Size 55.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d6ceba48f739aa6eeb7ed12b9728bcff2b2aa7cb4de642e5cdffe543d1ee9ca
BLAKE2b-256 checksum
How to use checksums
a458712d12c045aa9d37947a72afcb2f1497bcdbad5d04ce9b7324062731b916
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Security for sundgren 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sundgren-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page