diff --git a/qt6-after/qt6-migrated-legatus/README.md b/qt6-after/qt6-migrated-legatus/README.md index c58db27e9..dc9184c6c 100644 --- a/qt6-after/qt6-migrated-legatus/README.md +++ b/qt6-after/qt6-migrated-legatus/README.md @@ -270,6 +270,12 @@ the tree: - `coverage.info` — lcov tracefile, filtered to `qt-migration-legatus/*` - `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 path under the pipeline root (relative values are ignored and the default above is used). The option is mutually exclusive with diff --git a/qt6-after/qt6-migrated-legatus/new_docker_build.sh b/qt6-after/qt6-migrated-legatus/new_docker_build.sh index ac89218a9..099bca0c7 100755 --- a/qt6-after/qt6-migrated-legatus/new_docker_build.sh +++ b/qt6-after/qt6-migrated-legatus/new_docker_build.sh @@ -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