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)/' "$@"