Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,14 @@ download_file(
urls = ["https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-2da3e7b/clang-format-19_linux-amd64"],
)

bazel_dep(name = "aspect_rules_lint", version = "2.3.0", dev_dependency = True)
bazel_dep(name = "score_cpp_policies", dev_dependency = True)
git_override(
module_name = "score_cpp_policies",
commit = "d762cc5cd9fe6ce5920c0f246303662f71a698ee",
remote = "https://github.com/eclipse-score/score_cpp_policies.git",
)

bazel_dep(name = "aspect_rules_lint", version = "2.5.0", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.6.1", dev_dependency = True)
bazel_dep(name = "google_benchmark", version = "1.9.5", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1", dev_dependency = True)
Expand Down
2 changes: 1 addition & 1 deletion quality/coverage/coverage.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ coverage --extra_toolchains=@ferrocene_x86_64_unknown_linux_gnu_llvm//:rust_ferr
# Use llvm-cov directly for HTML report generation instead of genhtml/lcov.
# The custom merger (per-test) receives profraw files and produces a zip with profdata + HTML.
# The custom reporter (final) merges all profdata and generates the combined HTML report.
coverage --coverage_output_generator=//quality/coverage/llvm_cov:merger
coverage --coverage_output_generator=@score_cpp_policies//coverage:merger
coverage --coverage_report_generator=//quality/coverage/llvm_cov:reporter_wrapper
coverage --experimental_fetch_all_coverage_outputs

Expand Down
4 changes: 2 additions & 2 deletions quality/coverage/generate_coverage_html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ if [[ -f "${JUSTIFICATION_YAML}" ]]; then
mkdir -p "${JUSTIFICATION_DIR}"

# Run justify.py via Bazel to produce the resolved manifest.
if bazel run //quality/coverage/llvm_cov:justify -- \
if bazel run @score_cpp_policies//coverage:justify -- \
--yaml "${JUSTIFICATION_YAML}" \
--source-root "${BUILD_WORKSPACE_DIRECTORY}" \
--output "${JUSTIFICATION_DIR}/manifest.json"; then

# Run effective_coverage.py via Bazel to post-process HTML and calculate effective coverage.
bazel run //quality/coverage/llvm_cov:effective_coverage -- \
bazel run @score_cpp_policies//coverage:effective_coverage -- \
--html-dir "${OUTPUT_DIR}" \
--manifest "${JUSTIFICATION_DIR}/manifest.json" \
--output "${JUSTIFICATION_DIR}/report.json"
Expand Down
76 changes: 19 additions & 57 deletions quality/coverage/llvm_cov/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,67 +11,29 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

py_binary(
name = "merger",
srcs = ["merger.py"],
load(
"@score_cpp_policies//coverage:defs.bzl",
"score_coverage_reporter",
"score_instrumented_sources_manifest",
)

py_binary(
name = "reporter",
srcs = ["reporter.py"],
data = [
"filter_regexes.txt",
"//:MODULE.bazel",
"@llvm_toolchain//:llvm-cov",
"@llvm_toolchain//:llvm-profdata",
# Collect all C++ source files reachable from the main library targets so that
# files not linked into any test show up at 0% in the coverage report.
score_instrumented_sources_manifest(
name = "instrumented_sources",
targets = [
"//score/message_passing:message_passing",
"//score/mw/com:com",
],
deps = ["@rules_python//python/runfiles"],
)

genrule(
name = "reporter_wrapper_gen",
srcs = [
"filter_regexes.txt",
"//:MODULE.bazel",
],
outs = ["reporter_wrapper.sh"],
cmd = """
cat > $@ << EOF
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "\\$${RUNFILES_DIR:-}" ]]; then
if [[ -d "\\$$0.runfiles" ]]; then
export RUNFILES_DIR="\\$$0.runfiles"
fi
fi
WORKSPACE_ROOT="\\$$(cd "\\$$(dirname "\\$$(readlink -f "\\$${RUNFILES_DIR}/$(rlocationpath //:MODULE.bazel)")")" && pwd)/"
exec "\\$${RUNFILES_DIR}/_main/quality/coverage/llvm_cov/reporter" \\\\
--filter_regexes="$(rlocationpath filter_regexes.txt)" \\\\
--workspace_root="\\$${WORKSPACE_ROOT}" \\\\
"\\$$@"
EOF
chmod +x $@
""",
)

sh_binary(
# Wrapper target wiring in the LLVM toolchain binaries and the workspace root.
# Referenced by coverage.bazelrc via:
# coverage --coverage_report_generator=//quality/coverage/llvm_cov:reporter_wrapper
score_coverage_reporter(
name = "reporter_wrapper",
srcs = [":reporter_wrapper_gen"],
data = [":reporter"],
)

py_binary(
name = "justify",
srcs = ["justify.py"],
deps = [
"@score_communication_pip//pyyaml",
],
)

py_binary(
name = "effective_coverage",
srcs = ["effective_coverage.py"],
instrumented_sources_manifest = ":instrumented_sources",
llvm_cov = "@llvm_toolchain//:llvm-cov",
llvm_profdata = "@llvm_toolchain//:llvm-profdata",
visibility = ["//visibility:public"],
)
Loading
Loading