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
@@ -270,6 +270,12 @@ the tree:
|
|||||||
- `coverage.info` — lcov tracefile, filtered to `qt-migration-legatus/*`
|
- `coverage.info` — lcov tracefile, filtered to `qt-migration-legatus/*`
|
||||||
- `coverage_summary.txt` — totals (line / branch hit rate)
|
- `coverage_summary.txt` — totals (line / branch hit rate)
|
||||||
|
|
||||||
|
Source paths inside `coverage.info` and the html report are rewritten
|
||||||
|
to host paths at the end of the collection (the container mount prefix
|
||||||
|
is replaced by the pipeline root), so the report works directly on the
|
||||||
|
host. Note: the files are created by root inside the container — read
|
||||||
|
them as-is, or `chown` the directory on the host to edit/move it.
|
||||||
|
|
||||||
`--coverage-output-dir DIR` moves the report; `DIR` must be an absolute
|
`--coverage-output-dir DIR` moves the report; `DIR` must be an absolute
|
||||||
path under the pipeline root (relative values are ignored and the
|
path under the pipeline root (relative values are ignored and the
|
||||||
default above is used). The option is mutually exclusive with
|
default above is used). The option is mutually exclusive with
|
||||||
|
|||||||
@@ -357,8 +357,7 @@ if [[ "${RUN_COVERAGE}" == "ON" ]]; then
|
|||||||
log_info "Collecting code coverage (lcov)..."
|
log_info "Collecting code coverage (lcov)..."
|
||||||
OS_VERSION=$(eval $(grep "^VERSION_ID=" /etc/os-release) && echo "$VERSION_ID")
|
OS_VERSION=$(eval $(grep "^VERSION_ID=" /etc/os-release) && echo "$VERSION_ID")
|
||||||
COV_DIR="${DOCKER_MOUNT_ROOT}/coverage/${PROJECT}/${OS_VERSION}"
|
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
|
case "${COVERAGE_OUTPUT_DIR}" in
|
||||||
/*)
|
/*)
|
||||||
if [[ "${COVERAGE_OUTPUT_DIR}" == "${MIGRATE_PIPELINE_ROOT}"/* ]]; then
|
if [[ "${COVERAGE_OUTPUT_DIR}" == "${MIGRATE_PIPELINE_ROOT}"/* ]]; then
|
||||||
@@ -366,11 +365,13 @@ if [[ "${RUN_COVERAGE}" == "ON" ]]; then
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
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}"
|
rm -rf "${COV_DIR}"
|
||||||
mkdir -p "${COV_DIR}"
|
mkdir -p "${COV_DIR}"
|
||||||
cd "${BUILD_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"
|
LCOV_IGNORE_ERRORS="mismatch,unused,source,category,version,gcov,corrupt,unsupported,inconsistent,count"
|
||||||
# 1) capture all instrumented objects under the build tree
|
# 1) capture all instrumented objects under the build tree
|
||||||
lcov --capture --directory . \
|
lcov --capture --directory . \
|
||||||
@@ -396,7 +397,16 @@ if [[ "${RUN_COVERAGE}" == "ON" ]]; then
|
|||||||
lcov --summary "${COV_DIR}/coverage.info" --rc branch_coverage=1 \
|
lcov --summary "${COV_DIR}/coverage.info" --rc branch_coverage=1 \
|
||||||
--ignore-errors="${LCOV_IGNORE_ERRORS}" \
|
--ignore-errors="${LCOV_IGNORE_ERRORS}" \
|
||||||
> "${COV_DIR}/coverage_summary.txt"
|
> "${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"
|
cat "${COV_DIR}/coverage_summary.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user