From e72119f1eeb3f54f54a23fd57d5f5967bc4532b2 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 21 Nov 2019 15:06:30 +0200 Subject: CI: add test coverage results This runs the coverage tools to produce HTML pages listing the code lines / functions / branches hit/totalled by the test suite. Nowadays Gitlab has some Cobertura support itself: https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html lcov is needed for the HTML report, gcovr is needed for the Cobertura report. 'ninja clean' must be removed, otherwise it deletes the coverage files before they are analysed. Seeing the test suite code coverage is really interesting. It can guide designing tests. If Gitlab MRs show the coverage in diff view, it shows if new code actually gets executed in CI. Signed-off-by: Pekka Paalanen --- .gitlab-ci.yml | 18 ++++++++++++++---- .gitlab-ci/debian-install.sh | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 755bb874..e5b1aa89 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ stages: variables: FDO_DISTRIBUTION_VERSION: buster FDO_DISTRIBUTION_EXEC: 'bash .gitlab-ci/debian-install.sh' - FDO_DISTRIBUTION_TAG: '2021-02-25.1' + FDO_DISTRIBUTION_TAG: '2021-03-04.1' container_prep: @@ -67,7 +67,6 @@ container_prep: - virtme-run --rw --pwd --kimg /weston-virtme/bzImage --script-dir ../.gitlab-ci/virtme-scripts - TEST_RES=$(cat $TESTS_RES_PATH) - rm $TESTS_RES_PATH - - ninja clean - cp -R /weston-virtme ./ - rm weston-virtme/bzImage - exit $TEST_RES @@ -103,8 +102,16 @@ container_prep: build-native-meson-default-options: variables: MESON_OPTIONS: > + -Doptimization=0 + -Db_coverage=true -Dwerror=true extends: .build-native-meson + after_script: + - ninja -C build-* coverage-html + - ninja -C build-* coverage-xml + artifacts: + reports: + cobertura: build-*/meson-logs/coverage.xml build-docs: variables: @@ -123,17 +130,20 @@ build-native-meson-no-gl-renderer: -Dwerror=true extends: .build-native-meson -preview-docs: +docs-and-coverage: stage: pages script: - mv prefix-weston-build-docs/share/doc/weston Documentation + - mv build-weston-build-native-meson-default-options/meson-logs/coveragereport Test_Coverage - rm -rf build-* prefix-* dependencies: - build-docs + - build-native-meson-default-options artifacts: - expose_as: 'Documentation preview' + expose_as: 'Documentation preview and test coverage report' paths: - Documentation/ + - Test_Coverage/ pages: stage: pages diff --git a/.gitlab-ci/debian-install.sh b/.gitlab-ci/debian-install.sh index 9ac9446e..4cad75a4 100644 --- a/.gitlab-ci/debian-install.sh +++ b/.gitlab-ci/debian-install.sh @@ -36,7 +36,9 @@ apt-get -y --no-install-recommends install \ build-essential \ curl \ doxygen \ + gcovr \ git \ + lcov \ libasound2-dev \ libbluetooth-dev \ libcairo2-dev \ -- cgit v1.2.1