chore wire opt-in test coverage with bisect_ppx

Coverage was unmeasured despite a healthy test volume. Every library now declares bisect_ppx as an optional instrumentation backend. dune activates it only when asked, so ordinary builds are untouched and the package need not be installed for development. scripts/coverage.sh asks: it rebuilds the tests instrumented, runs them, and renders an HTML report or a one-line summary. It refuses clearly when bisect_ppx is not installed rather than failing mid-build.

Commit
6c008443eb2eb7151bd6d10b71140267c67dd124
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
.gitignore
index ae282e11..4abc6df8 100644..100644
@@ -28,3 +28,7 @@
28 28 *.sqlite-wal
29 29 *.sqlite-shm
30 30 *.sqlite-journal
31 Added:
32 Added: # Coverage output
33 Added: _coverage/
34 Added: _bisect/
lib/app/dune
index 307229f0..77e9f6bd 100644..100644
@@ -5,5 +5,7 @@
5 5
6 6 (library
7 7 (name hito_app)
8 Added: (instrumentation
9 Added: (backend bisect_ppx))
8 10 (public_name hito.app)
9 11 (libraries hito.core lwt))
lib/core/dune
index 50abe08f..942aec5f 100644..100644
@@ -4,6 +4,8 @@
4 4
5 5 (library
6 6 (name hito_core)
7 Added: (instrumentation
8 Added: (backend bisect_ppx))
7 9 (public_name hito.core)
8 10 (modules exercise recovery prescription routines feedback evidence progress)
9 11 (wrapped false))
lib/import/dune
index 94c248c8..26b736f0 100644..100644
@@ -5,5 +5,7 @@
5 5
6 6 (library
7 7 (name hito_import)
8 Added: (instrumentation
9 Added: (backend bisect_ppx))
8 10 (public_name hito.import)
9 11 (libraries hito.core hito.app csv))
lib/persistence/dune
index 82029e03..86edee1b 100644..100644
@@ -4,6 +4,8 @@
4 4
5 5 (library
6 6 (name hito_persistence)
7 Added: (instrumentation
8 Added: (backend bisect_ppx))
7 9 (public_name hito.persistence)
8 10 (libraries
9 11 hito.core
lib/presenter/dune
index bd0155e4..fec1346b 100644..100644
@@ -3,6 +3,8 @@
3 3
4 4 (library
5 5 (name hito_presenter)
6 Added: (instrumentation
7 Added: (backend bisect_ppx))
6 8 (public_name hito.presenter)
7 9 (modules
8 10 page_kit
lib/web/dune
index 7788d42a..bd3423fe 100644..100644
@@ -37,6 +37,8 @@
37 37
38 38 (library
39 39 (name hito_web)
40 Added: (instrumentation
41 Added: (backend bisect_ppx))
40 42 (public_name hito.web)
41 43 (modules
42 44 decode
scripts/coverage.sh
index 00000000..551c88d2 000000..100755
@@ -0,0 +1,40 @@
1 Added: #!/usr/bin/env sh
2 Added: # Test coverage with bisect_ppx.
3 Added: #
4 Added: # Every library declares bisect_ppx as an optional instrumentation backend.
5 Added: # dune only activates it when asked, so ordinary builds never touch coverage
6 Added: # and the package need not be installed for development. This script asks:
7 Added: # it rebuilds the tests instrumented, runs them, and renders the report.
8 Added: #
9 Added: # Requires: opam install bisect_ppx
10 Added: #
11 Added: # Usage: scripts/coverage.sh HTML report in _coverage/index.html
12 Added: # scripts/coverage.sh summary one-line summary on stdout
13 Added:
14 Added: set -eu
15 Added:
16 Added: BUILD_DIR="${BUILD_DIR:-_build-coverage}"
17 Added: DATA_DIR="$(pwd)/_bisect"
18 Added:
19 Added: if ! command -v bisect-ppx-report >/dev/null 2>&1; then
20 Added: printf 'coverage: bisect-ppx-report is not installed. Run: opam install bisect_ppx\n' >&2
21 Added: exit 2
22 Added: fi
23 Added:
24 Added: rm -rf "$DATA_DIR" _coverage
25 Added: mkdir -p "$DATA_DIR"
26 Added:
27 Added: # Instrumented test run. BISECT_FILE tells the instrumented code where to write
28 Added: # its counters, one file per process.
29 Added: BISECT_FILE="$DATA_DIR/bisect" \
30 Added: dune runtest --build-dir "$BUILD_DIR" --force --instrument-with bisect_ppx
31 Added:
32 Added: case "${1:-html}" in
33 Added: summary)
34 Added: bisect-ppx-report summary --coverage-path "$DATA_DIR"
35 Added: ;;
36 Added: *)
37 Added: bisect-ppx-report html --coverage-path "$DATA_DIR" -o _coverage
38 Added: printf '==> report: _coverage/index.html\n'
39 Added: ;;
40 Added: esac