Skip to content

ci: require Python for the tests and measure their coverage with a floor - #26

Merged
SizzleUnrlsd merged 3 commits into
mainfrom
test/coverage
Sep 27, 2026
Merged

SizzleUnrlsd merged 3 commits into
mainfrom
test/coverage

Conversation

@SizzleUnrlsd

@SizzleUnrlsd SizzleUnrlsd commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Item 5 of #21, the last one: closes #21. Stacked on #25 (test/cli-unit): merge #22 to #25 first.

Change

  1. build: fail configuration without Python 3. The fixtures, cli, timeout and compile_failure tests are Python scripts; without an interpreter, configuration used to succeed and the suite ran without them, silently. find_package(Python3 REQUIRED) when the tests are configured. The README also said CMake 3.16 where 3.21 has been required since the release archives.
  2. ci: measure the suite's coverage with llvm-cov and fail below a floor. -DCORETRACE_COVERAGE=ON instruments this project's own targets (the library, the CLI, the unit tests) at -O0 for source-based coverage, as ctrace does; fetched dependencies are not. scripts/ci/coverage.sh <build> <out> [<floor>] runs the suite with LLVM_PROFILE_FILE set (the Python tests spawn the CLI many times, %4m merges per binary), merges the profiles, reports src/, include/ and main.cpp per file, writes an HTML report, adds the totals to the job summary, and fails below the floor. The coverage job of the Build workflow runs it on Ubuntu 24.04 with clang-20 and uploads the report.
  3. The floor. It started at 100 so that the job's first run failed and showed the value reached on Linux: 89.20% of lines, the same as on macOS. ci: set the coverage floor at 89% of lines sets it just under, to be raised as tests land.

Tests (written first)

  • Python: configured with -DPython3_EXECUTABLE=/nonexistent/python3, the tree used to configure with "Could NOT find Python3" and four tests fewer; it now fails at configuration.
  • Coverage: the script's first local run, floor 100, fails as it should and reports (macOS, AppleClang, xcrun llvm-cov):
File Lines Functions
src/cli_args.cpp 98.29% 100%
src/events.cpp 100% 100%
src/findings.cpp 93.75% 100%
src/process.cpp 58.06% 100%
src/runtime_analyzer.cpp 90.14% 100%
src/sarif.cpp 100% 100%
src/shipped_toolchain.cpp 100% 100%
total 89.20% 100%

process.cpp reads the same on Linux: its child-side code between fork and exec never reaches a profile, and its pipe, fork and waitpid failure paths are not provoked.

Verification

  • macOS arm64: ctest --test-dir build 17/17 on the instrumented tree; ./scripts/format-check.sh clean.
  • Linux: this pull request's Build workflow. The coverage job failed once at floor 100, as meant, and passes at 89.

The fixtures, cli, timeout and compile_failure tests are Python scripts.
Without an interpreter, configuration used to succeed and the suite ran
without them, silently. Python 3 is now required when the tests are
configured. The README also said CMake 3.16 where 3.21 has been required
since the release archives.

Part of #21.
-DCORETRACE_COVERAGE=ON instruments this project's own targets (the
library, the CLI and the unit tests) at -O0 for source-based coverage;
fetched dependencies are not. scripts/ci/coverage.sh runs the suite with
LLVM_PROFILE_FILE set, merges the profiles, reports src/, include/ and
main.cpp per file, writes an HTML report, adds the totals to the GitHub
Actions job summary, and fails when the line coverage is below the floor
it is given.

The coverage job of the Build workflow runs it on Ubuntu 24.04 with
clang-20 and uploads the report. Its floor starts at 100 so that the first
run shows the value reached; the next commit sets it there.

Locally on macOS (AppleClang, xcrun llvm-cov): 89.20% of lines, 100% of
functions; process.cpp is the low file at 58%, the other platform's paths.

Part of #21.
The first run of the coverage job on Ubuntu 24.04 with clang-20 measured
89.20% of lines and 100% of functions, the same as the local macOS run.
process.cpp is the low file at 58%: its child-side code between fork and
exec never reaches a profile, and its pipe, fork and waitpid failure paths
are not provoked. The floor is set just under the value reached, to be
raised as tests land.

Part of #21.
Base automatically changed from test/cli-unit to main September 27, 2026 15:14
@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 27, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit 8002b6c into main Sep 27, 2026
7 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the test/coverage branch October 23, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: cover the library API, the CLI options and every fixture, and measure it

1 participant