Fix coverage paths: report and artifacts use host paths, not /repo
- new_docker_build.sh: the coverage log now prints the host-side report location (<pipeline-root>/coverage/<project>/<os>); after genhtml, the container mount prefix is rewritten to the host path in coverage.info (SF: lines), the html path labels/cmd_line and coverage_summary.txt. The rewrite is plain text replacement after genhtml because genhtml must run in the container, where the sources exist under the mount root (lcov --substitute rewrites before the extract filter and would leave genhtml unable to read the sources). - README.md: document the host-path rewrite and the root ownership of the artifacts.
This commit is contained in:
1 parent
72c87230fd
commit
2f82acd7e0
2 files changed
+21
-5
No files matched your search
@@ -357,8 +357,7 @@ if [[ "${RUN_COVERAGE}" == "ON" ]]; then
|
||||
log_info "Collecting code coverage (lcov)..."
|
||||
OS_VERSION=$(eval $(grep "^VERSION_ID=" /etc/os-release) && echo "$VERSION_ID")
|
||||
COV_DIR="${DOCKER_MOUNT_ROOT}/coverage/${PROJECT}/${OS_VERSION}"
|
||||
# Honor --coverage-output-dir when it is an absolute path under the
|
||||
# pipeline root (the only place the host can see it inside the container).
|
||||
|
||||
case "${COVERAGE_OUTPUT_DIR}" in
|
||||
/*)
|
||||
if [[ "${COVERAGE_OUTPUT_DIR}" == "${MIGRATE_PIPELINE_ROOT}"/* ]]; then
|
||||
@@ -366,11 +365,13 @@ if [[ "${RUN_COVERAGE}" == "ON" ]]; then
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# Host-side equivalent of COV_DIR (COV_DIR is the container-side path
|
||||
# used by the lcov steps; the report is consumed on the host).
|
||||
COV_HOST_DIR="${MIGRATE_PIPELINE_ROOT}${COV_DIR#"${DOCKER_MOUNT_ROOT}"}"
|
||||
rm -rf "${COV_DIR}"
|
||||
mkdir -p "${COV_DIR}"
|
||||
cd "${BUILD_DIR}"
|
||||
# gcov data quirks under -O0 (exception-tag mismatches, inlined-lambda
|
||||
# consistency checks, ...): suppressed so the steps below don't abort.
|
||||
|
||||
LCOV_IGNORE_ERRORS="mismatch,unused,source,category,version,gcov,corrupt,unsupported,inconsistent,count"
|
||||
# 1) capture all instrumented objects under the build tree
|
||||
lcov --capture --directory . \
|
||||
@@ -396,7 +397,16 @@ if [[ "${RUN_COVERAGE}" == "ON" ]]; then
|
||||
lcov --summary "${COV_DIR}/coverage.info" --rc branch_coverage=1 \
|
||||
--ignore-errors="${LCOV_IGNORE_ERRORS}" \
|
||||
> "${COV_DIR}/coverage_summary.txt"
|
||||
log_info "Coverage report: ${COV_DIR} (html/index.html, coverage.info, coverage_summary.txt)"
|
||||
# 5) rewrite the container mount prefix to the host path in the
|
||||
# artifacts (tracefile SF: lines, html path labels and cmd_line), so
|
||||
# the report is usable on the host. Done as plain text replacement
|
||||
# AFTER genhtml: genhtml must run in the container, where the
|
||||
# sources exist under the mount root (the host paths do not).
|
||||
sed -i "s|^SF:${DOCKER_MOUNT_ROOT}/|SF:${MIGRATE_PIPELINE_ROOT}/|" "${COV_DIR}/coverage.info"
|
||||
sed -i "s|${DOCKER_MOUNT_ROOT}/|${MIGRATE_PIPELINE_ROOT}/|g" "${COV_DIR}/coverage_summary.txt"
|
||||
find "${COV_DIR}/html" -type f \( -name '*.html' -o -name 'cmd_line' \) \
|
||||
-exec sed -i "s|${DOCKER_MOUNT_ROOT}/|${MIGRATE_PIPELINE_ROOT}/|g" {} +
|
||||
log_info "Coverage report: ${COV_HOST_DIR} (html/index.html, coverage.info, coverage_summary.txt)"
|
||||
cat "${COV_DIR}/coverage_summary.txt"
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user