From ba4de0ea3b4c69aec2b745b7174411d6867828e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=C3=B6rderer?= Date: Mon, 18 Apr 2022 13:15:14 +0200 Subject: [PATCH] Fix list options in configuration files. (#612) --- CHANGELOG.rst | 3 ++- gcovr/configuration.py | 11 +++++------ gcovr/tests/config-output/config/gcovr.config | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 33a0d5694..a8def1d68 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -26,7 +26,8 @@ Bug fixes and small improvements: - Use `≥` sign instead of `>=` in HTML legend. (:issue:`603`) - Using :option:`--add-tracefile` will now correctly merge branch coverage. (:issue:`600`) - Fix package-level function coverage statistics in Cobertura XML reports. (:issue:`605`) -- Respect excluded/noncode lines for aggregated branch coverage. (:issue:`611`) +- Respect excluded/noncode lines for aggregated branchcoverage. (:issue:`611`) +- Fix list options in configuration file (search-path). (:issue:`612`) Documentation: diff --git a/gcovr/configuration.py b/gcovr/configuration.py index 1b2179908..10d136d6c 100644 --- a/gcovr/configuration.py +++ b/gcovr/configuration.py @@ -523,12 +523,7 @@ def _assign_value_to_dict( option: GcovrConfigOption, is_single_value: bool, ) -> None: - - if option.action in ("store", "store_const"): - namespace[option.name] = value - return - - if option.action == "append": + if option.action == "append" or option.nargs == "*": append_target = namespace.setdefault(option.name, []) if is_single_value: append_target.append(value) @@ -536,6 +531,10 @@ def _assign_value_to_dict( append_target.extend(value) return + if option.action in ("store", "store_const"): + namespace[option.name] = value + return + assert False, f"unexpected action for {option.name}: {option.action!r}" diff --git a/gcovr/tests/config-output/config/gcovr.config b/gcovr/tests/config-output/config/gcovr.config index 0e9ffd127..d807d1a44 100644 --- a/gcovr/tests/config-output/config/gcovr.config +++ b/gcovr/tests/config-output/config/gcovr.config @@ -1,3 +1,4 @@ html-css=style.css output=../coverage.html filter=.* +search-path=../