Meta: Generate one coverage report per library

This allows us to see the coverage of each library without transitive
usages. As an example, Vector::clone() is never tested directly in
Tests/AK, and it's coverage depends on an external test or library. This
means that its coverage is fragile as the code using it in tests might
be dropped in the future.
This commit is contained in:
Lucas Chollet committed 2026-10-14 09:14:25 +02:00
1 parent 7dea0e2eb8
commit bd4bcd52be
1 file changed
+24 -9
+24 -9
View File
@@ -54,16 +54,31 @@ PROF_DATA_FILES=$(find "$TEMP_PROFDATA/profiles/" -name "*.profdata")
# shellcheck disable=SC2086
$PROFDATA_INVOCATION $PROF_DATA_FILES -o "$GLOBAL_PROFILE"
# Generate reports
echo "Discovering all binaries and shared libraries in $BUILD_DIR/Root"
# shellcheck disable=SC2156 # The recommended fix on the Shellcheck github page for this warning causes the script to not find any files at all
all_binaries=$(find "$BUILD_DIR"/Root -type f -executable -exec sh -c "file {} | grep -vi relocatable | grep -Eiq ': elf (32|64)-bit'" \; -printf "-object %p\n" | grep -Ev '(usr\/local|boot\/|Loader.so)')
echo "Generating global html report"
# shellcheck disable=SC2086
$LLVM_COV show $all_binaries \
-format html \
-instr-profile "$GLOBAL_PROFILE" \
-o "$BUILD_DIR/reports" \
-show-line-counts-or-regions -show-directory-coverage \
-Xdemangler "$CLANG_BINDIR/llvm-cxxfilt" -Xdemangler -n \
-compilation-dir="${SERENITY_ROOT}"
LLVM_COV_INVOCATION="$LLVM_COV show $all_binaries"
LLVM_COV_INVOCATION+=" -format html "
LLVM_COV_INVOCATION+=" -show-line-counts-or-regions -show-directory-coverage "
LLVM_COV_INVOCATION+=" -Xdemangler $CLANG_BINDIR/llvm-cxxfilt -Xdemangler -n "
LLVM_COV_INVOCATION+=" -compilation-dir=$SERENITY_ROOT "
LLVM_COV_INVOCATION+=" -ignore-filename-regex=(Meta|Tests|Build|Kernel) "
for dir in $LIBRARY_DIRS;
do
library=$(basename "$dir")
echo "Generating report for $library"
# FIXME: Filtering out useless binaries would speed-up these calls.
$LLVM_COV_INVOCATION \
-instr-profile "$TEMP_PROFDATA/profiles/$library/$library.profdata" \
-o "$BUILD_DIR/reports/$library" \
-include-filename-regex="\/$library\/"
done
echo "Generating global report"
$LLVM_COV_INVOCATION \
-instr-profile "$GLOBAL_PROFILE" \
-o "$BUILD_DIR/reports/global/"