Move the coverage report into the build tree and document manual commands
- new_docker_build.sh: the default coverage report location is now qt6-after/build/coverage/<project>/<os>/ (inside the build tree, wiped with it on every run). - README.md: new 'Manual commands (without the driver)' section with the exact image build, container start, from-zero cmake/ninja compile, ctest and instrumented lcov coverage pipeline; Step 6 and the options table updated to the new report location. - Verified end to end: clean from-zero --run-coverage run, 22/22 tests, 122 production files, host-side paths in all artifacts.
This commit is contained in:
1 parent
363bde9a0e
commit
f1f2c5eec8
2 files changed
+103
-6
No files matched your search
@@ -261,10 +261,10 @@ ctest suite and collects an lcov report inside the container
|
||||
./new_docker_build.sh --run-coverage
|
||||
```
|
||||
|
||||
The report is written to
|
||||
`<pipeline-root>/coverage/<PROJECT>/<OS_VERSION>/` (default:
|
||||
`coverage/guez/26.04/`), next to `qt-migration-legatus/` and outside
|
||||
the tree:
|
||||
The report is written inside the build tree (default:
|
||||
`qt6-after/build/coverage/<PROJECT>/<OS_VERSION>/`, e.g.
|
||||
`qt6-after/build/coverage/guez/26.04/`); like the build itself, it is
|
||||
wiped at the start of every driver run:
|
||||
|
||||
- `html/index.html` — browser report (line + branch coverage)
|
||||
- `coverage.info` — lcov tracefile: production code only. Test sources
|
||||
@@ -284,6 +284,101 @@ path under the pipeline root (relative values are ignored and the
|
||||
default above is used). The option is mutually exclusive with
|
||||
`--run-jenkins-builder`.
|
||||
|
||||
## Manual commands (without the driver)
|
||||
|
||||
Everything the driver does, by hand. `PIPELINE_ROOT` is the directory
|
||||
that contains `qt-migration-legatus/` (the driver mounts it as `/repo`).
|
||||
|
||||
### 1. Build the image
|
||||
|
||||
```bash
|
||||
cd qt-migration-legatus/qt6-after/qt6-migrated-legatus # the tree
|
||||
docker build -t legatus-qt6:1.0 -f Dockerfile .
|
||||
```
|
||||
|
||||
### 2. Start the container
|
||||
|
||||
```bash
|
||||
PIPELINE_ROOT=/home/nkana/release_2/qt6-migration-pipeline
|
||||
docker run --rm -it \
|
||||
-v "${PIPELINE_ROOT}":/repo \
|
||||
-w /repo/qt-migration-legatus/qt6-after/qt6-migrated-legatus \
|
||||
legatus-qt6:1.0 /bin/bash
|
||||
```
|
||||
|
||||
### 3. Compile from zero (inside the container)
|
||||
|
||||
```bash
|
||||
rm -rf ../build && mkdir -p ../build
|
||||
cmake -B ../build \
|
||||
-G Ninja \
|
||||
-DBUILD_TESTING=ON \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_PREFIX_PATH=/opt/Qt/6.10.2/gcc_64 \
|
||||
"-DCMAKE_CXX_FLAGS=-DRTI_LINUX -DRTI_UNIX" \
|
||||
"-DCMAKE_C_FLAGS=-DRTI_LINUX -DRTI_UNIX" \
|
||||
-DBUILD_RTI=ON \
|
||||
-DBUILD_GROUP1=ON -DBUILD_GROUP3=ON -DBUILD_GROUP5=ON -DBUILD_GROUP6=ON \
|
||||
.
|
||||
cmake --build ../build -j$(nproc)
|
||||
```
|
||||
|
||||
(the driver builds the 61 Release 2 targets one by one instead of the
|
||||
default `all` target, for finer progress logs and fail-fast — see the
|
||||
`GROUP*_TARGETS` arrays in `new_docker_build.sh`)
|
||||
|
||||
### 4. Run the tests
|
||||
|
||||
```bash
|
||||
cd ../build
|
||||
export QT_QPA_PLATFORM=offscreen
|
||||
export QT_PLUGIN_PATH="/usr/lib/x86_64-linux-gnu/qt6/plugins"
|
||||
ctest --output-on-failure -j$(nproc)
|
||||
```
|
||||
|
||||
### 5. Coverage (manual)
|
||||
|
||||
First reconfigure the build instrumented — add these four flags to the
|
||||
cmake configure in step 3 (then `cmake --build ../build -j$(nproc)` and
|
||||
run ctest as in step 4):
|
||||
|
||||
```bash
|
||||
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O0 -g --coverage -DNDEBUG -fPIC" \
|
||||
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O0 -g --coverage -DNDEBUG -fPIC" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS=--coverage \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS=--coverage \
|
||||
```
|
||||
|
||||
Then collect, from the build directory (inside the container):
|
||||
|
||||
```bash
|
||||
cd ../build
|
||||
COV_DIR="$PWD/coverage/guez/26.04"
|
||||
IGNORE="mismatch,unused,source,category,version,gcov,corrupt,unsupported,inconsistent,count"
|
||||
rm -rf "$COV_DIR" && mkdir -p "$COV_DIR"
|
||||
lcov --capture --directory . \
|
||||
--output-file "$COV_DIR/coverage_raw.info" \
|
||||
--rc branch_coverage=1 --ignore-errors="$IGNORE"
|
||||
lcov --extract "$COV_DIR/coverage_raw.info" "/repo/qt-migration-legatus/*" \
|
||||
--output-file "$COV_DIR/coverage.info" \
|
||||
--rc branch_coverage=1 --ignore-errors="$IGNORE"
|
||||
rm -f "$COV_DIR/coverage_raw.info"
|
||||
lcov --remove "$COV_DIR/coverage.info" \
|
||||
"*/qt6-after/build/*" "*/unit-test/*" "*/UnitTests/*" \
|
||||
"*unit_test*" "*/tests/*" \
|
||||
--output-file "$COV_DIR/_filtered.info" \
|
||||
--rc branch_coverage=1 --ignore-errors="$IGNORE"
|
||||
mv -f "$COV_DIR/_filtered.info" "$COV_DIR/coverage.info"
|
||||
genhtml "$COV_DIR/coverage.info" --output-directory "$COV_DIR/html" \
|
||||
--branch-coverage --title "Legatus Qt6 Release 2 - code coverage" \
|
||||
--ignore-errors="$IGNORE"
|
||||
lcov --summary "$COV_DIR/coverage.info" --rc branch_coverage=1 \
|
||||
--ignore-errors="$IGNORE" > "$COV_DIR/coverage_summary.txt"
|
||||
```
|
||||
|
||||
Note: by hand the report keeps the container paths (`/repo/...`); the
|
||||
driver additionally rewrites them to the host `PIPELINE_ROOT` (Step 6).
|
||||
|
||||
## Options reference
|
||||
|
||||
`./new_docker_build.sh --help` prints the full option list.
|
||||
@@ -305,7 +400,7 @@ The main ones:
|
||||
| `--package-output-dir DIR` | `./packages-out` | pass-through (see Step 4 note) |
|
||||
| `--lts-version / --project / --build-number / --build-tag` | `1.0` / `guez` / `1` / `manual-build` | package metadata |
|
||||
| `--run-coverage` | off | instrument with `-O0 --coverage`, run ctest, collect the lcov report (Step 6); mutually exclusive with `--run-jenkins-builder` |
|
||||
| `--coverage-output-dir DIR` | `<pipeline-root>/coverage/<project>/<os>` | report dir — only absolute paths under the pipeline root are honored (Step 6) |
|
||||
| `--coverage-output-dir DIR` | `qt6-after/build/coverage/<project>/<os>` | report dir (inside the build tree) — only absolute paths under the pipeline root are honored (Step 6) |
|
||||
|
||||
Environment overrides: `BUILD_GROUP1/3/5/6`, `RUN_CTEST`, `TESTS_ONLY`,
|
||||
`USE_PREBUILT_IMAGE`, `DOCKER_IMAGE`, `CMAKE_BUILD_FLAGS`,
|
||||
|
||||
@@ -356,7 +356,9 @@ fi
|
||||
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}"
|
||||
# Default location: inside the build tree (wiped at the start of every
|
||||
# driver run, like the rest of the build).
|
||||
COV_DIR="${BUILD_DIR}/coverage/${PROJECT}/${OS_VERSION}"
|
||||
|
||||
case "${COVERAGE_OUTPUT_DIR}" in
|
||||
/*)
|
||||
|
||||
Reference in new issue
Block a user