From 4c7226e3632704e38606839cc962b27d44cd32e3 Mon Sep 17 00:00:00 2001 From: Andrew McNulty Date: Sat, 12 Oct 2024 11:15:45 +0100 Subject: [PATCH] coverage.py: Guard use of `--html-nested` behind version check. `--html-nested` was added to gcovr in version 6.0 so passing it to versions before this will result in gcovr complaining that it doesn't recognise the argument. Added a version check to ensure that we pass a recognised argument for versions before 6.0 Fixes #13781 --- mesonbuild/scripts/coverage.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mesonbuild/scripts/coverage.py b/mesonbuild/scripts/coverage.py index f01946944afe..a4dfebfb9d9b 100644 --- a/mesonbuild/scripts/coverage.py +++ b/mesonbuild/scripts/coverage.py @@ -159,9 +159,14 @@ def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build htmloutdir = os.path.join(log_dir, 'coveragereport') if not os.path.isdir(htmloutdir): os.mkdir(htmloutdir) + # Use `--html-details` if gcovr version < 6.0, otherwise + # use `--html-nested`. + html_arg = '--html-details' + if mesonlib.version_compare(gcovr_version, '>=6.0'): + html_arg = '--html-nested' subprocess.check_call(gcovr_base_cmd + gcovr_config + ['--html', - '--html-nested', + html_arg, '--print-summary', '-o', os.path.join(htmloutdir, 'index.html'), ] + gcov_exe_args)