Skip to content

Commit

Permalink
coverage: Enable coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda authored and jpakkane committed Jun 22, 2021
1 parent edfe241 commit 765aff5
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 116 deletions.
50 changes: 0 additions & 50 deletions .coveragerc

This file was deleted.

7 changes: 5 additions & 2 deletions .github/workflows/cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ jobs:
- name: Run pip
run: |
export PATH=/usr/bin:/usr/local/bin:$(cygpath ${SYSTEMROOT})/system32
python3 -m pip --disable-pip-version-check install gcovr jsonschema pefile pytest pytest-xdist
python3 -m pip --disable-pip-version-check install gcovr jsonschema pefile pytest pytest-xdist coverage codecov
shell: C:\cygwin\bin\bash.exe --noprofile --norc -o igncr -eo pipefail '{0}'

- name: Run tests
run: |
export PATH=/usr/bin:/usr/local/bin:$(cygpath ${SYSTEMROOT})/system32
python3 run_tests.py --backend=ninja
python3 ./tools/run_with_cov.py run_tests.py --backend=ninja
env:
# Cygwin's static boost installation is broken (some static library
# variants such as boost_thread are not present)
Expand All @@ -87,3 +87,6 @@ jobs:
path: meson-test-run.*
# test log should be saved on failure
if: ${{ !cancelled() }}

- name: Upload coverage report
run: ./ci/upload_cov.sh "${{ matrix.NAME }}"
13 changes: 9 additions & 4 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
python-version: '3.x'
- run: |
python -m pip install --upgrade pip
python -m pip install pytest pytest-xdist jsonschema
python -m pip install pytest pytest-xdist jsonschema coverage codecov
- run: brew install pkg-config ninja llvm qt@5
- env:
CPPFLAGS: "-I/usr/local/include"
Expand All @@ -35,7 +35,10 @@ jobs:
export SDKROOT="$(xcodebuild -version -sdk macosx Path)"
export PATH="$HOME/tools:/usr/local/opt/qt@5/bin:$PATH:$(brew --prefix llvm)/bin"
export PKG_CONFIG_PATH="/usr/local/opt/qt@5/lib/pkgconfig:$PKG_CONFIG_PATH"
./run_unittests.py
./tools/run_with_cov.py ./run_unittests.py
- name: Upload coverage report
run: ./ci/upload_cov.sh "appleclang [unit tests]"


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

Qt4macos:
runs-on: macos-latest
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Install dependencies
run: |
python3 -m pip --disable-pip-version-check install gcovr jsonschema pefile pytest pytest-xdist
python3 -m pip --disable-pip-version-check install gcovr jsonschema pefile pytest pytest-xdist coverage codecov
- name: Run Tests
run: |
Expand All @@ -89,9 +89,12 @@ jobs:
pacman --noconfirm --needed -S mingw-w64-${{ matrix.MSYS2_ARCH }}-${{ matrix.MSYS2_CURSES }}
fi
MSYSTEM= python3 run_tests.py --backend=ninja
MSYSTEM= python3 ./tools/run_with_cov.py run_tests.py --backend=ninja
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.NAME }}
path: meson-test-run.*

- name: Upload coverage report
run: ./ci/upload_cov.sh "${{ matrix.NAME }}"
5 changes: 4 additions & 1 deletion .github/workflows/nonative.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- run: |
apt-get -y purge clang gcc gdc
apt-get -y autoremove
python3 -m pip install coverage codecov
- uses: actions/checkout@v2
- name: Run tests
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./run_tests.py $CI_ARGS --cross ubuntu-armhf.json --cross-only'
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'
- name: Upload coverage report
run: ./ci/upload_cov.sh "Ubuntu nonnative"
9 changes: 7 additions & 2 deletions .github/workflows/os_comp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ jobs:
# All environment variables are stored inside the docker image in /ci/env_vars.sh
# They are defined in the `env` section in each image.json. CI_ARGS should be set
# via the `args` array ub the image.json
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./run_tests.py $CI_ARGS'
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./tools/run_with_cov.py ./run_tests.py $CI_ARGS'
- name: Upload coverage report
run: ./ci/upload_cov.sh "OS Comp [${{ matrix.cfg.name }}]"

ubuntu-rolling:
name: 'Ubuntu Rolling'
Expand Down Expand Up @@ -106,4 +108,7 @@ jobs:
update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix
update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
./run_tests.py $RUN_TESTS_ARGS -- $MESON_ARGS
./tools/run_with_cov.py ./run_tests.py $RUN_TESTS_ARGS -- $MESON_ARGS
- name: Upload coverage report
run: ./ci/upload_cov.sh "Ubuntu [${{ matrix.cfg.CC }} ${{ matrix.cfg.RUN_TESTS_ARGS }} ${{ matrix.cfg.MESON_ARGS }}]"
12 changes: 9 additions & 3 deletions .github/workflows/unusedargs_missingreturn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ jobs:
run: |
sudo apt update -yq
sudo apt install -yq --no-install-recommends g++ gfortran ninja-build gobjc gobjc++
- run: python run_project_tests.py --only cmake common fortran platform-linux "objective c" "objective c++"
python -m pip install coverage codecov
- run: ./tools/run_with_cov.py run_project_tests.py --only cmake common fortran platform-linux "objective c" "objective c++"
- name: Upload coverage report
run: ./ci/upload_cov.sh "UnusedMissingReturn"

windows:
runs-on: windows-latest
Expand All @@ -55,10 +58,13 @@ jobs:
with:
python-version: '3.x'

- run: pip install ninja pefile
- run: pip install ninja pefile coverage codecov

- run: python run_project_tests.py --only platform-windows
- run: python ./tools/run_with_cov.py run_project_tests.py --only platform-windows
env:
CC: gcc
CXX: g++
FC: gfortran

- name: Upload coverage report
run: ./ci/upload_cov.sh "UnusedMissingReturn Windows"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/.vscode

__pycache__
.coverage
/.coverage/
/.coveragerc
/install dir
/work area

Expand Down
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ trigger:

variables:
CI: 1
SOURCE_VERSION: $(Build.SourceVersion)

jobs:

Expand Down
19 changes: 17 additions & 2 deletions ci/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,26 @@ python --version

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

echo ""
echo "=== Start running tests ==="
# Starting from VS2019 Powershell(?) will fail the test run
# if it prints anything to stderr. Python's test runner
# does that by default so we need to forward it.
cmd /c "python 2>&1 run_tests.py --backend $env:backend $env:extraargs"
cmd /c "python 2>&1 ./tools/run_with_cov.py run_tests.py --backend $env:backend $env:extraargs"

echo ""
echo ""
echo "=== Gathering coverage report ==="
echo ""

python3 -m coverage combine
python3 -m coverage xml
python3 -m coverage report

# Currently codecov.py does not handle Azure, use this fork of a fork to get it
# working without requireing a token
git clone https://github.com/mensinda/codecov-python
python3 -m pip install --ignore-installed ./codecov-python
python3 -m codecov -f .coverage/coverage.xml -n "VS$env:compiler $env:arch $env:backend" -c $env:SOURCE_VERSION
13 changes: 13 additions & 0 deletions ci/upload_cov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

echo "Combining coverage reports..."
coverage combine

echo "Generating XML report..."
coverage xml

echo "Printing report"
coverage report

echo "Uploading to codecov..."
codecov -f .coverage/coverage.xml -n "$1"
19 changes: 19 additions & 0 deletions ci/usercustomize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 The Meson development team

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script is used by coverage (see tools/run_with_cov.py) to enable coverage
# reports in python subprocesses

import coverage
coverage.process_startup()
25 changes: 25 additions & 0 deletions data/.coveragerc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[run]
branch = True
parallel = True
concurrency = multiprocessing
data_file = @ROOT@/.coverage/coverage
source = @ROOT@/mesonbuild/

[report]
exclude_lines =
if T.TYPE_CHECKING:

[paths]
mesonbuild =
mesonbuild/
__w/meson/meson/mesonbuild/
@ROOT@/mesonbuild/

[html]
directory = @ROOT@/.coverage/html

[xml]
output = @ROOT@/.coverage/coverage.xml

[json]
output = @ROOT@/.coverage/coverage.json
Loading

0 comments on commit 765aff5

Please sign in to comment.