Re: [yocto-patches] [wic][PATCH v3 04/10] tests: add optional coverage reporting to run-tests.sh
Paul Barker <[email protected]> Mon, 06 Jul 2026 09:33:24 +0100
| Newsgroups | org.yoctoproject.lists.yocto-patches |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2026-07-01 at 03:40 -0400, Trevor Woerner via lists.yoctoproject.org wrote: > Knowing which lines a test run actually exercised is the difference > between "the suite is green" and "the suite is green and we know what > it touched". This commit wires branch coverage of the wic source into > the runner, kept entirely opt-in so a plain run stays fast and quiet. > > pyproject.toml gains coverage and pytest-cov in the tests extra, so > "pip install -e .[tests]" pulls in what the new flags need. > > run-tests.sh gains two options: > > - --coverage measures branch coverage of src/wic during the run and > prints a terminal report listing the lines that were missed; > > - --html [DIR] additionally writes a browsable HTML report (default > htmlcov/, or DIR if given) and implies --coverage. > > If --coverage is requested but pytest-cov is not installed the runner > fails loudly with the install command rather than running without the > measurement it was asked for. > > The coverage data file and the HTML report directory are build > artifacts, so .gitignore learns to ignore .coverage and htmlcov/. > > AI-Generated: codex/claude-opus 4.7 (xhigh) > Signed-off-by: Trevor Woerner <[email protected]> Ok, now the run-tests.sh script starts to make sense. Have you considered something like `just` (https://github.com/casey/just) as a command runner? It's much simpler to maintain a `justfile` than a shell script. Using claude (opus 4.8) to convert run-tests.sh (as it is at the end of this series of patches) to a much simpler justfile, I get: # List the available recipes. default: @just --list # Run the test suite. Extra args pass through to pytest (e.g. `just test -k filemap`). test *args="tests": pytest {{args}} # Run the suite with a terminal branch-coverage report for wic. coverage *args="tests": pytest {{args}} --cov=wic --cov-branch --cov-report=term-missing # Run the suite with an HTML coverage report (default dir: htmlcov/). coverage-html dir="htmlcov" *args="tests": pytest {{args}} --cov=wic --cov-branch --cov-report=term-missing --cov-report=html:{{dir}} # Lint the test suite; held to a clean bar, so this must report nothing. lint-tests: ruff check tests # Lint src/ (not yet ruff-clean, so this is a preview report, not a gate). lint: lint-tests ruff check src Feel free to keep the shell script if you want to, but I think the above is easier to maintain :) Best regards, -- Paul Barker
signature.asc
(application/pgp-signature, 252 B)
-----BEGIN PGP SIGNATURE----- iIcEABYKAC8WIQSzjPXf5Y1BDWhU2iCrY1Tsnbr0bgUCaktoVBEccGF1bEBwYmFy a2VyLmRldgAKCRCrY1Tsnbr0bhBHAP9J/bmhRK0sQhwkoTnOwFXzc/n7l2aKWSJg Wv3IcwZiwwD9EfnG33QgjOQMulMjhfPC1rsB3AeCkm8C9RdSDWZIfAo= =+84/ -----END PGP SIGNATURE-----