#!/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}" # The dependency tree is fully vendored, so the instrumented builds run offline by # default; override with CARGO_LLVM_COV_FLAGS if you need something else. read -ra CARGO_FLAGS <<<"${CARGO_LLVM_COV_FLAGS:---offline}" # 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 for the GUI and the artifact/flash/CLI crates. cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" -p alkane-gui --bin alkane-toolkit cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" \ -p alkane-artifacts -p alkane-flash -p alkane-cli # 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 "${CARGO_FLAGS[@]}" --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)/' "$@"