summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2022-03-27 16:37:54 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2022-03-27 18:37:35 +0200
commit3bb23925f80f77d8a3d94f48e83f532e3846870e (patch)
treebcb15201be9435dbf4cd8a24c1b00d1eae6cc6a2
parent94ec4ba56206470417109d1cead6ac999f8bd977 (diff)
downloadpygobject-3bb23925f80f77d8a3d94f48e83f532e3846870e.tar.gz
coverage: include Python coverage in lcov report
newer pycoverage supports lcov as output format, so convert to lcov and only generate one report at the end for everything. The lcov report isn't that nice, but at least everything is in one place.
-rw-r--r--.gitlab-ci.yml1
-rwxr-xr-x.gitlab-ci/coverage-docker.sh21
-rw-r--r--.gitlab-ci/fixup-lcov-paths.py33
-rwxr-xr-x.gitlab-ci/test-docker-old.sh1
-rwxr-xr-x.gitlab-ci/test-docker.sh1
-rwxr-xr-x.gitlab-ci/test-flatpak-gtk4.sh1
-rwxr-xr-x.gitlab-ci/test-msys2.sh1
7 files changed, 31 insertions, 28 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a1a1a9b5..024654bd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -38,6 +38,7 @@ coverage:
PYENV_VERSION: "3.7.13-debug"
script:
- bash -x ./.gitlab-ci/coverage-docker.sh
+ coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
pages:
stage: deploy
diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh
index 3072c2fe..a1b271ee 100755
--- a/.gitlab-ci/coverage-docker.sh
+++ b/.gitlab-ci/coverage-docker.sh
@@ -2,11 +2,8 @@
set -e
-python -m pip install coverage
-
# Make the Windows paths match our current layout
python ./.gitlab-ci/fixup-lcov-paths.py coverage/*.lcov
-python ./.gitlab-ci/fixup-covpy-paths.py coverage/.coverage*
# Remove external headers (except gi tests)
for path in coverage/*.lcov; do
@@ -17,25 +14,9 @@ for path in coverage/*.lcov; do
lcov --config-file .gitlab-ci/lcovrc -r "${path}" '*tmp-introspect*' -o "${path}"
done
-python -m coverage combine coverage
-python -m coverage html --show-contexts --ignore-errors -d coverage/report-python
genhtml --ignore-errors=source --config-file .gitlab-ci/lcovrc \
- coverage/*.lcov -o coverage/report-c
+ coverage/*.lcov -o coverage/
cd coverage
rm -f .coverage*
rm -f *.lcov
-
-ln -s report-python/index.html index-python.html
-ln -s report-c/index.html index-c.html
-
-cat >index.html <<EOL
-<html>
-<body>
-<ul>
-<li><a href="report-c/index.html">C Coverage</a></li>
-<li><a href="report-python/index.html">Python Coverage</a></li>
-</ul>
-</body>
-</html>
-EOL
diff --git a/.gitlab-ci/fixup-lcov-paths.py b/.gitlab-ci/fixup-lcov-paths.py
index ecd77425..e8555c75 100644
--- a/.gitlab-ci/fixup-lcov-paths.py
+++ b/.gitlab-ci/fixup-lcov-paths.py
@@ -1,6 +1,5 @@
import sys
import os
-import io
import re
@@ -11,15 +10,33 @@ def main(argv):
for path in paths:
print("cov-fixup:", path)
- text = io.open(path, "r", encoding="utf-8").read()
- text = text.replace("\\\\", "/")
+ with open(path, "r", encoding="utf-8") as h:
+ text = h.read()
+
+ text = text.replace("\\\\", "/").replace("\\", "/")
new_root = os.getcwd()
+
+ def make_abs(m):
+ p = m.group(1)
+ if p.startswith("C:/"):
+ p = p.replace("C:/", "/c/")
+ if not p.startswith("/"):
+ p = os.path.join(new_root, p)
+ return "SF:" + p
+
+ text = re.sub("SF:(.*?)$", make_abs, text, 0, re.MULTILINE)
+
+ canidate = None
for old_root in set(re.findall(":(.*?)/gi/.*?$", text, re.MULTILINE)):
- 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 canidate is None or len(old_root) < len(canidate):
+ canidate = old_root
+
+ if canidate:
+ print("replacing %r with %r" % (canidate, new_root))
+ text = text.replace(canidate, new_root)
+
+ with open(path, "w", encoding="utf-8") as h:
+ h.write(text)
if __name__ == "__main__":
diff --git a/.gitlab-ci/test-docker-old.sh b/.gitlab-ci/test-docker-old.sh
index c06f7ee2..8d88bd35 100755
--- a/.gitlab-ci/test-docker-old.sh
+++ b/.gitlab-ci/test-docker-old.sh
@@ -20,3 +20,4 @@ python -m pip install --upgrade pip
python -m pip install pycairo pytest pytest-faulthandler coverage
python setup.py build_tests
xvfb-run -a python -m coverage run --context "${COV_KEY}" tests/runtests.py
+python -m coverage lcov -o "${COV_DIR}/${COV_KEY}.py.lcov"
diff --git a/.gitlab-ci/test-docker.sh b/.gitlab-ci/test-docker.sh
index bb865a01..d44641dd 100755
--- a/.gitlab-ci/test-docker.sh
+++ b/.gitlab-ci/test-docker.sh
@@ -52,6 +52,7 @@ lcov --config-file .gitlab-ci/lcovrc --directory . --capture --initial --output-
"${COV_DIR}/${CI_JOB_NAME}-baseline.lcov"
xvfb-run -a python -m coverage run --context "${COV_KEY}" tests/runtests.py
+python -m coverage lcov -o "${COV_DIR}/${COV_KEY}.py.lcov"
# COLLECT GCOV COVERAGE
lcov --config-file .gitlab-ci/lcovrc --directory . --capture --output-file \
diff --git a/.gitlab-ci/test-flatpak-gtk4.sh b/.gitlab-ci/test-flatpak-gtk4.sh
index 320a107f..a299b641 100755
--- a/.gitlab-ci/test-flatpak-gtk4.sh
+++ b/.gitlab-ci/test-flatpak-gtk4.sh
@@ -11,4 +11,5 @@ export TEST_GTK_VERSION=4.0
python3 -m pip install --user pytest pytest-faulthandler coverage
python3 setup.py build_tests
python3 -m coverage run --context "${COV_KEY}" tests/runtests.py
+python3 -m coverage lcov -o "${COV_DIR}/${COV_KEY}.py.lcov"
chmod -R 777 "${COV_DIR}" \ No newline at end of file
diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh
index 8cd39afd..045fef17 100755
--- a/.gitlab-ci/test-msys2.sh
+++ b/.gitlab-ci/test-msys2.sh
@@ -47,6 +47,7 @@ lcov \
"${COV_DIR}/${COV_KEY}-baseline.lcov"
MSYSTEM= python -m coverage run --context "${COV_KEY}" tests/runtests.py
+MSYSTEM= python -m coverage lcov -o "${COV_DIR}/${COV_KEY}.py.lcov"
lcov \
--config-file .gitlab-ci/lcovrc \