From 73f13554fd0eecbd0e7eb3c40775d380313e696f Mon Sep 17 00:00:00 2001 From: noah Date: Wed, 23 Sep 2026 08:09:02 -0600 Subject: [PATCH] coverage: count the headless self-test, reporting ~46% (was ~35%) The self-test builds the real wxWidgets table and renders every fixture through the real widgets, exercising ~27% of ui.rs (up from ~4%) -- but it runs as a separate binary, so a plain `cargo llvm-cov` (which only runs the #[test]s) never counted it, understating coverage. New ci/coverage.sh runs both the unit tests and the self-test under one instrumentation pass and merges them, excluding the vendored asic-rs / patched wx-rs from the report. Our-source line coverage is now ~46% (model 81%, naming 95%, fixtures 100%, credentials 92%); the remainder is click-driven dialogs and live-miner network I/O, which unit tests can't reach without hardware or heavy mocks. Badge, report, and README dev section updated. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6 --- README.md | 1 + badges/coverage.svg | 10 +++++----- ci/coverage.sh | 33 +++++++++++++++++++++++++++++++++ code-review-report.md | 10 +++++++--- 4 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 ci/coverage.sh diff --git a/README.md b/README.md index 8b162922..094f9971 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ cargo test -p alkane-gui --release -- --ignored bench_ # microbenchmarks cargo clippy -p alkane-gui --no-deps --bins -- -D warnings # lint gate xvfb-run -a env ALKANE_SELFTEST=1 \ "$CARGO_TARGET_DIR/release/alkane-toolkit" # headless UI self-test +ci/coverage.sh --summary-only # coverage (tests + self-test) ``` CI mirrors these: `verify.yml` runs the lint, tests, benchmarks, self-test, and diff --git a/badges/coverage.svg b/badges/coverage.svg index c1343502..8ab63323 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1,5 +1,5 @@ - - coverage: 35% + + coverage: 46% @@ -7,13 +7,13 @@ - + coverage coverage - 35% - 35% + 46% + 46% diff --git a/ci/coverage.sh b/ci/coverage.sh new file mode 100644 index 00000000..2464513e --- /dev/null +++ b/ci/coverage.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Measure line coverage from BOTH the unit tests AND the headless UI self-test. +# +# The self-test (ALKANE_SELFTEST=1) builds the real wxWidgets table, renders every +# fixture through the real widgets, and checks each cell against the model -- it +# exercises most of ui.rs. Because it runs as a separate binary invocation, a plain +# `cargo llvm-cov` (which only runs the #[test]s) never counts it, so ui.rs shows +# ~4% even though it is integration-tested. This combines both runs' coverage. +# +# Usage: ci/coverage.sh [extra `cargo llvm-cov report` args, e.g. --summary-only] +set -euo pipefail + +export WX_RS_WXCONFIG="${WX_RS_WXCONFIG:-$HOME/.cache/wx-3.3.3-linux/bin/wx-config}" + +# A display for the self-test's real widgets. +need_xvfb() { command -v xvfb-run >/dev/null 2>&1; } + +cargo llvm-cov clean --workspace + +# 1. Unit tests. +cargo llvm-cov --no-report -p alkane-gui --bin alkane-toolkit + +# 2. Headless UI self-test, under the same instrumentation, its coverage appended. +if need_xvfb; then + xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 \ + cargo llvm-cov run --no-report --bin alkane-toolkit +else + echo "coverage.sh: xvfb-run not found; skipping the self-test run (unit tests only)" >&2 +fi + +# 3. Merged report, our source only (vendored asic-rs + the patched wx-rs bridge +# are out of scope). +cargo llvm-cov report --ignore-filename-regex '(thirdparty|vendor)/' "$@" diff --git a/code-review-report.md b/code-review-report.md index d33a3d50..898ed86b 100644 --- a/code-review-report.md +++ b/code-review-report.md @@ -40,9 +40,13 @@ because each round re-confirms unresolved/accepted items). - Source: ~12.5k lines in `crates/alkane-gui` (the other `crates/alkane-*` are early scaffolding); vendored `asic-rs` + patched `wx-rs` are out of scope. - Tests: 99 unit tests + a headless UI self-test; microbenchmarks run in CI. -- Line coverage: ~36% overall; the pure logic is well covered (model 77%, naming - 95%, fixtures 100%, credentials 92%), with the wxWidgets UI-construction code - exercised by the self-test rather than unit tests. +- Line coverage: ~46% of our source (unit tests + the headless self-test, via + `ci/coverage.sh`). The pure logic is well covered (model 81%, naming 95%, + fixtures 100%, credentials 92%); the rest is click-driven dialogs and live + network I/O, which unit tests can't reach without hardware or heavy mocks. + (A tests-only run reports ~35% because the self-test, which exercises ~27% of + ui.rs by rendering real widgets, runs as a separate binary that a plain + `cargo llvm-cov` never counts -- `ci/coverage.sh` merges both runs.) - Lint: `cargo clippy --no-deps -- -D warnings` clean on our crate. ## Fixed (by class)