glib/.gitlab-ci/fixup-cov-paths.py
Christoph Reiter 7d1e782c65 CI: Re-enable code coverage reporting for MSYS2 builds
It was disabled in !875 because lcov didn't support the new coverage
format produced by gcc9+. The latest lcov release in MSYS2 supports
it again, so re-enable everything.

lcov now writes native Windows paths to its output so adjust the path
fixup script to handle those.
2020-10-01 14:07:14 +02:00

27 lines
755 B
Python

import sys
import os
import io
import re
def main(argv):
# Fix paths in lcov files generated on a Windows host so they match our
# current source layout.
paths = argv[1:]
for path in paths:
print("cov-fixup:", path)
text = io.open(path, "r", encoding="utf-8").read()
text = text.replace("\\\\", "/")
old_root = re.search(":(.*?)/glib/.*?$", text, re.MULTILINE).group(1)
new_root = os.path.dirname(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))