Skip to content

Commit 765aff5

Browse files
mensindajpakkane
authored andcommitted
coverage: Enable coverage reports
1 parent edfe241 commit 765aff5

16 files changed

+205
-116
lines changed

Diff for: .coveragerc

-50
This file was deleted.

Diff for: .github/workflows/cygwin.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ jobs:
6868
- name: Run pip
6969
run: |
7070
export PATH=/usr/bin:/usr/local/bin:$(cygpath ${SYSTEMROOT})/system32
71-
python3 -m pip --disable-pip-version-check install gcovr jsonschema pefile pytest pytest-xdist
71+
python3 -m pip --disable-pip-version-check install gcovr jsonschema pefile pytest pytest-xdist coverage codecov
7272
shell: C:\cygwin\bin\bash.exe --noprofile --norc -o igncr -eo pipefail '{0}'
7373

7474
- name: Run tests
7575
run: |
7676
export PATH=/usr/bin:/usr/local/bin:$(cygpath ${SYSTEMROOT})/system32
77-
python3 run_tests.py --backend=ninja
77+
python3 ./tools/run_with_cov.py run_tests.py --backend=ninja
7878
env:
7979
# Cygwin's static boost installation is broken (some static library
8080
# variants such as boost_thread are not present)
@@ -87,3 +87,6 @@ jobs:
8787
path: meson-test-run.*
8888
# test log should be saved on failure
8989
if: ${{ !cancelled() }}
90+
91+
- name: Upload coverage report
92+
run: ./ci/upload_cov.sh "${{ matrix.NAME }}"

Diff for: .github/workflows/macos.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
python-version: '3.x'
2525
- run: |
2626
python -m pip install --upgrade pip
27-
python -m pip install pytest pytest-xdist jsonschema
27+
python -m pip install pytest pytest-xdist jsonschema coverage codecov
2828
- run: brew install pkg-config ninja llvm qt@5
2929
- env:
3030
CPPFLAGS: "-I/usr/local/include"
@@ -35,7 +35,10 @@ jobs:
3535
export SDKROOT="$(xcodebuild -version -sdk macosx Path)"
3636
export PATH="$HOME/tools:/usr/local/opt/qt@5/bin:$PATH:$(brew --prefix llvm)/bin"
3737
export PKG_CONFIG_PATH="/usr/local/opt/qt@5/lib/pkgconfig:$PKG_CONFIG_PATH"
38-
./run_unittests.py
38+
./tools/run_with_cov.py ./run_unittests.py
39+
- name: Upload coverage report
40+
run: ./ci/upload_cov.sh "appleclang [unit tests]"
41+
3942

4043
project-tests-appleclang:
4144
runs-on: macos-latest
@@ -50,7 +53,7 @@ jobs:
5053
- run: |
5154
python3 -m pip install --upgrade setuptools
5255
python3 -m pip install --upgrade pip
53-
python3 -m pip install cython
56+
python3 -m pip install cython coverage codecov
5457
- env:
5558
CPPFLAGS: "-I/usr/local/include"
5659
LDFLAGS: "-L/usr/local/lib"
@@ -61,7 +64,9 @@ jobs:
6164
export SDKROOT="$(xcodebuild -version -sdk macosx Path)"
6265
export PATH="$HOME/tools:/usr/local/opt/qt@5/bin:$PATH:$(brew --prefix llvm)/bin"
6366
export PKG_CONFIG_PATH="/usr/local/opt/qt@5/lib/pkgconfig:$PKG_CONFIG_PATH"
64-
./run_project_tests.py --backend=ninja
67+
./tools/run_with_cov.py ./run_project_tests.py --backend=ninja
68+
- name: Upload coverage report
69+
run: ./ci/upload_cov.sh "appleclang [project tests; unity=${{ matrix.unity }}]"
6570

6671
Qt4macos:
6772
runs-on: macos-latest

Diff for: .github/workflows/msys2.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
7272
- name: Install dependencies
7373
run: |
74-
python3 -m pip --disable-pip-version-check install gcovr jsonschema pefile pytest pytest-xdist
74+
python3 -m pip --disable-pip-version-check install gcovr jsonschema pefile pytest pytest-xdist coverage codecov
7575
7676
- name: Run Tests
7777
run: |
@@ -89,9 +89,12 @@ jobs:
8989
pacman --noconfirm --needed -S mingw-w64-${{ matrix.MSYS2_ARCH }}-${{ matrix.MSYS2_CURSES }}
9090
fi
9191
92-
MSYSTEM= python3 run_tests.py --backend=ninja
92+
MSYSTEM= python3 ./tools/run_with_cov.py run_tests.py --backend=ninja
9393
9494
- uses: actions/upload-artifact@v2
9595
with:
9696
name: ${{ matrix.NAME }}
9797
path: meson-test-run.*
98+
99+
- name: Upload coverage report
100+
run: ./ci/upload_cov.sh "${{ matrix.NAME }}"

Diff for: .github/workflows/nonative.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- run: |
2727
apt-get -y purge clang gcc gdc
2828
apt-get -y autoremove
29+
python3 -m pip install coverage codecov
2930
- uses: actions/checkout@v2
3031
- name: Run tests
31-
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./run_tests.py $CI_ARGS --cross ubuntu-armhf.json --cross-only'
32+
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./tools/run_with_cov.py ./run_tests.py $CI_ARGS --cross ubuntu-armhf.json --cross-only'
33+
- name: Upload coverage report
34+
run: ./ci/upload_cov.sh "Ubuntu nonnative"

Diff for: .github/workflows/os_comp.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ jobs:
4040
# All environment variables are stored inside the docker image in /ci/env_vars.sh
4141
# They are defined in the `env` section in each image.json. CI_ARGS should be set
4242
# via the `args` array ub the image.json
43-
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./run_tests.py $CI_ARGS'
43+
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./tools/run_with_cov.py ./run_tests.py $CI_ARGS'
44+
- name: Upload coverage report
45+
run: ./ci/upload_cov.sh "OS Comp [${{ matrix.cfg.name }}]"
4446

4547
ubuntu-rolling:
4648
name: 'Ubuntu Rolling'
@@ -106,4 +108,7 @@ jobs:
106108
update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix
107109
update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
108110
109-
./run_tests.py $RUN_TESTS_ARGS -- $MESON_ARGS
111+
./tools/run_with_cov.py ./run_tests.py $RUN_TESTS_ARGS -- $MESON_ARGS
112+
113+
- name: Upload coverage report
114+
run: ./ci/upload_cov.sh "Ubuntu [${{ matrix.cfg.CC }} ${{ matrix.cfg.RUN_TESTS_ARGS }} ${{ matrix.cfg.MESON_ARGS }}]"

Diff for: .github/workflows/unusedargs_missingreturn.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ jobs:
4545
run: |
4646
sudo apt update -yq
4747
sudo apt install -yq --no-install-recommends g++ gfortran ninja-build gobjc gobjc++
48-
- run: python run_project_tests.py --only cmake common fortran platform-linux "objective c" "objective c++"
48+
python -m pip install coverage codecov
49+
- run: ./tools/run_with_cov.py run_project_tests.py --only cmake common fortran platform-linux "objective c" "objective c++"
50+
- name: Upload coverage report
51+
run: ./ci/upload_cov.sh "UnusedMissingReturn"
4952

5053
windows:
5154
runs-on: windows-latest
@@ -55,10 +58,13 @@ jobs:
5558
with:
5659
python-version: '3.x'
5760

58-
- run: pip install ninja pefile
61+
- run: pip install ninja pefile coverage codecov
5962

60-
- run: python run_project_tests.py --only platform-windows
63+
- run: python ./tools/run_with_cov.py run_project_tests.py --only platform-windows
6164
env:
6265
CC: gcc
6366
CXX: g++
6467
FC: gfortran
68+
69+
- name: Upload coverage report
70+
run: ./ci/upload_cov.sh "UnusedMissingReturn Windows"

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
/.vscode
99

1010
__pycache__
11-
.coverage
11+
/.coverage/
12+
/.coveragerc
1213
/install dir
1314
/work area
1415

Diff for: azure-pipelines.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ trigger:
99

1010
variables:
1111
CI: 1
12+
SOURCE_VERSION: $(Build.SourceVersion)
1213

1314
jobs:
1415

Diff for: ci/run.ps1

+17-2
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,26 @@ python --version
6868

6969
# Needed for running unit tests in parallel.
7070
echo ""
71-
python -m pip --disable-pip-version-check install --upgrade pefile pytest-xdist jsonschema
71+
python -m pip --disable-pip-version-check install --upgrade pefile pytest-xdist jsonschema coverage
7272

7373
echo ""
7474
echo "=== Start running tests ==="
7575
# Starting from VS2019 Powershell(?) will fail the test run
7676
# if it prints anything to stderr. Python's test runner
7777
# does that by default so we need to forward it.
78-
cmd /c "python 2>&1 run_tests.py --backend $env:backend $env:extraargs"
78+
cmd /c "python 2>&1 ./tools/run_with_cov.py run_tests.py --backend $env:backend $env:extraargs"
79+
80+
echo ""
81+
echo ""
82+
echo "=== Gathering coverage report ==="
83+
echo ""
84+
85+
python3 -m coverage combine
86+
python3 -m coverage xml
87+
python3 -m coverage report
88+
89+
# Currently codecov.py does not handle Azure, use this fork of a fork to get it
90+
# working without requireing a token
91+
git clone https://github.com/mensinda/codecov-python
92+
python3 -m pip install --ignore-installed ./codecov-python
93+
python3 -m codecov -f .coverage/coverage.xml -n "VS$env:compiler $env:arch $env:backend" -c $env:SOURCE_VERSION

Diff for: ci/upload_cov.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
echo "Combining coverage reports..."
4+
coverage combine
5+
6+
echo "Generating XML report..."
7+
coverage xml
8+
9+
echo "Printing report"
10+
coverage report
11+
12+
echo "Uploading to codecov..."
13+
codecov -f .coverage/coverage.xml -n "$1"

Diff for: ci/usercustomize.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2021 The Meson development team
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This script is used by coverage (see tools/run_with_cov.py) to enable coverage
16+
# reports in python subprocesses
17+
18+
import coverage
19+
coverage.process_startup()

Diff for: data/.coveragerc.in

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[run]
2+
branch = True
3+
parallel = True
4+
concurrency = multiprocessing
5+
data_file = @ROOT@/.coverage/coverage
6+
source = @ROOT@/mesonbuild/
7+
8+
[report]
9+
exclude_lines =
10+
if T.TYPE_CHECKING:
11+
12+
[paths]
13+
mesonbuild =
14+
mesonbuild/
15+
__w/meson/meson/mesonbuild/
16+
@ROOT@/mesonbuild/
17+
18+
[html]
19+
directory = @ROOT@/.coverage/html
20+
21+
[xml]
22+
output = @ROOT@/.coverage/coverage.xml
23+
24+
[json]
25+
output = @ROOT@/.coverage/coverage.json

0 commit comments

Comments
 (0)