diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-02-23 11:02:03 +0100 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-02-23 16:37:17 +0100 |
commit | 2d812a6bc4d0952997a3ed3c63c4b09d8c95c103 (patch) | |
tree | 10d416492bd2e2e0030a60a2c9ac211122ea4c6c /.gitlab-ci | |
parent | 1534289ce5934b73b5c980f8e246192009337776 (diff) | |
download | pygobject-2d812a6bc4d0952997a3ed3c63c4b09d8c95c103.tar.gz |
gitlab-ci: Add Windows coverage support. See #168
Use coverage.py and cygwin lcov to generate coverage files.
In the report generation step fixup the Windows paths in the coverage
files to match the Linux/Docker ones.
Diffstat (limited to '.gitlab-ci')
-rwxr-xr-x | .gitlab-ci/coverage-docker.sh | 3 | ||||
-rw-r--r-- | .gitlab-ci/fixup-cov-paths.py | 35 | ||||
-rwxr-xr-x | .gitlab-ci/test-docker.sh | 5 | ||||
-rwxr-xr-x | .gitlab-ci/test-msys2.sh | 33 |
4 files changed, 74 insertions, 2 deletions
diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh index 6e74a797..0f1a0e9a 100755 --- a/.gitlab-ci/coverage-docker.sh +++ b/.gitlab-ci/coverage-docker.sh @@ -4,6 +4,9 @@ set -e python -m pip install coverage +# Make the Windows paths match our current layout +python ./.gitlab-ci/fixup-cov-paths.py coverage/.coverage* coverage/*.lcov + python -m coverage combine coverage python -m coverage html -d coverage/report-python genhtml --ignore-errors=source --rc lcov_branch_coverage=1 \ diff --git a/.gitlab-ci/fixup-cov-paths.py b/.gitlab-ci/fixup-cov-paths.py new file mode 100644 index 00000000..a6f43e44 --- /dev/null +++ b/.gitlab-ci/fixup-cov-paths.py @@ -0,0 +1,35 @@ +from __future__ import print_function + +import sys +import os +import io + + +def main(argv): + # Fix paths in coverage files to match our current source layout + # so that coverage report generators can find the source. + # Mostly needed for Windows. + paths = argv[1:] + + for path in paths: + print("cov-fixup:", path) + text = io.open(path, "r", encoding="utf-8").read() + text = text.replace("\\\\", "/") + end = text.index("/gi/") + try: + # coverage.py + start = text[:end].rindex("\"") + 1 + except ValueError: + # lcov + start = text[:end].rindex(":") + 1 + old_root = text[start:end] + new_root = os.getcwd() + if old_root != new_root: + print("replacing %r with %r" % (old_root, new_root)) + text = text.replace(old_root, new_root) + with io.open(path, "w", encoding="utf-8") as h: + h.write(text) + + +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff --git a/.gitlab-ci/test-docker.sh b/.gitlab-ci/test-docker.sh index 97d4805a..6d09b22d 100755 --- a/.gitlab-ci/test-docker.sh +++ b/.gitlab-ci/test-docker.sh @@ -4,6 +4,11 @@ set -e python --version +# ccache setup +mkdir -p _ccache +export CCACHE_BASEDIR="$(pwd)" +export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache" + python -m pip install git+https://github.com/pygobject/pycairo.git python -m pip install flake8 pytest pytest-faulthandler coverage diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh index 84c1c12c..9b44a8ff 100755 --- a/.gitlab-ci/test-msys2.sh +++ b/.gitlab-ci/test-msys2.sh @@ -2,6 +2,10 @@ set -e +# skip the fontconfig cache, it's slooowww +export MSYS2_FC_CACHE_SKIP=1 +export PANGOCAIRO_BACKEND=win32 + export PATH="/c/msys64/$MSYSTEM/bin:$PATH" if [[ "$MSYSTEM" == "MINGW32" ]]; then export MSYS2_ARCH="i686" @@ -14,15 +18,40 @@ pacman --noconfirm -Suy pacman --noconfirm -S --needed \ base-devel \ mingw-w64-$MSYS2_ARCH-toolchain \ + mingw-w64-$MSYS2_ARCH-ccache \ mingw-w64-$MSYS2_ARCH-$PYTHON-cairo \ mingw-w64-$MSYS2_ARCH-$PYTHON \ mingw-w64-$MSYS2_ARCH-$PYTHON-pip \ mingw-w64-$MSYS2_ARCH-$PYTHON-pytest \ + mingw-w64-$MSYS2_ARCH-$PYTHON-coverage \ mingw-w64-$MSYS2_ARCH-gobject-introspection \ mingw-w64-$MSYS2_ARCH-libffi \ mingw-w64-$MSYS2_ARCH-glib2 \ mingw-w64-$MSYS2_ARCH-gtk3 \ git \ - autoconf-archive + perl + +# ccache setup +export PATH="$MSYSTEM/lib/ccache/bin:$PATH" +mkdir -p _ccache +export CCACHE_BASEDIR="$(pwd)" +export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache" + +# coverage setup +export CFLAGS="-coverage -ftest-coverage -fprofile-arcs" +PYVER=$($PYTHON -c "import sys; sys.stdout.write(''.join(map(str, sys.version_info[:3])))") +COV_DIR="$(pwd)/coverage" +COV_KEY="${MSYSTEM}.${PYVER}" +mkdir -p "${COV_DIR}" +export COVERAGE_FILE="${COV_DIR}/.coverage.${COV_KEY}" + +$PYTHON setup.py build_tests +MSYSTEM= $PYTHON -m coverage run tests/runtests.py + +curl -O -J -L "https://github.com/linux-test-project/lcov/releases/download/v1.13/lcov-1.13.tar.gz" +tar -xvzf lcov-1.13.tar.gz -$PYTHON setup.py test +./lcov-1.13/bin/lcov \ + --rc lcov_branch_coverage=1 --no-external \ + --directory . --capture --output-file \ + "${COV_DIR}/${COV_KEY}.lcov" |