From 40d5a38d1b92826c46230e971524053d14a68ae4 Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Fri, 30 Jul 2021 11:10:12 +0200 Subject: Escape path in exclude filter passed to gcovr Gcovr interprets exclude filters, as passed to the -e option, as regexes. Since we want to exclude a raw path, the argument must be escaped. --- mesonbuild/scripts/coverage.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'mesonbuild/scripts/coverage.py') diff --git a/mesonbuild/scripts/coverage.py b/mesonbuild/scripts/coverage.py index 2bd93e8..a9e83c2 100644 --- a/mesonbuild/scripts/coverage.py +++ b/mesonbuild/scripts/coverage.py @@ -14,7 +14,7 @@ from mesonbuild import environment, mesonlib -import argparse, sys, os, subprocess, pathlib, stat +import argparse, re, sys, os, subprocess, pathlib, stat import typing as T def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build_root: str, log_dir: str, use_llvm_cov: bool) -> int: @@ -38,7 +38,7 @@ def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build if gcovr_exe: subprocess.check_call(gcovr_base_cmd + ['-x', - '-e', subproject_root, + '-e', re.escape(subproject_root), '-o', os.path.join(log_dir, 'coverage.xml') ] + gcov_exe_args) outfiles.append(('Xml', pathlib.Path(log_dir, 'coverage.xml'))) @@ -51,7 +51,7 @@ def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build subprocess.check_call(gcovr_base_cmd + ['--sonarqube', '-o', os.path.join(log_dir, 'sonarqube.xml'), - '-e', subproject_root + '-e', re.escape(subproject_root) ] + gcov_exe_args) outfiles.append(('Sonarqube', pathlib.Path(log_dir, 'sonarqube.xml'))) elif outputs: @@ -61,7 +61,7 @@ def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build if not outputs or 'text' in outputs: if gcovr_exe: subprocess.check_call(gcovr_base_cmd + - ['-e', subproject_root, + ['-e', re.escape(subproject_root), '-o', os.path.join(log_dir, 'coverage.txt') ] + gcov_exe_args) outfiles.append(('Text', pathlib.Path(log_dir, 'coverage.txt'))) @@ -140,7 +140,7 @@ def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build ['--html', '--html-details', '--print-summary', - '-e', subproject_root, + '-e', re.escape(subproject_root), '-o', os.path.join(htmloutdir, 'index.html'), ]) outfiles.append(('Html', pathlib.Path(htmloutdir, 'index.html'))) -- cgit v1.1