Test coverage for native code WIP

Part of: https://git.lix.systems/lix-project/lix/issues/1186
This commit is contained in:
Jade Lovelace
2026-04-19 18:01:00 +00:00
parent 1e986c81ab
commit c76cf49629
10 changed files with 239 additions and 3 deletions
+36
View File
@@ -0,0 +1,36 @@
# Early initialization of LLVM source-based coverage.
#
# Needs to run before defining any targets.
add_project_arguments(
'-fprofile-instr-generate',
'-fcoverage-mapping',
# TODO: -mllvm -runtime-counter-relocation may fix problems with tests with
# nix run/fmt/etc that execvp, bypassing atexit. need to confirm that's real.
language : 'cpp',
)
# N.B. This is a link argument because it needs to link the LLVM profiling runtime, I believe.
add_project_link_arguments(
'-fprofile-instr-generate',
language: 'cpp',
)
add_project_arguments(
'-Cinstrument-coverage',
language : 'rust',
)
coverage_profraw_dir = meson.project_build_root() / 'profraw'
run_command('mkdir', '-p', coverage_profraw_dir, check : true)
coverage_test_env = {
# TODO: may need %c, but that may only work if you set runtime counter relocation, need to find that out
#
# See: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program
# %20m -> use 20 raw profiles and merge at runtime, so that our large number of
# invocations of lix in the test suite don't create unreasonable numbers of
# files. This, I think, also limits the test concurrency.
'LLVM_PROFILE_FILE': coverage_profraw_dir / '%20m.profraw'
}
llvm_profdata = find_program('llvm-profdata', required : true)
llvm_cov = find_program('llvm-cov', required : true)