diff --git a/HISTORY.rst b/HISTORY.rst index 3e5be32d..c9e03460 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -23,6 +23,7 @@ PlatformIO Core 6 * Removed dependency on the "zeroconf" package and install it only when a user lists mDNS devices (issue with zeroconf's LGPL license) * Show the real error message instead of "Can not remove temporary directory" when |PIOCONF| is broken (`issue #4480 `_) * Fixed an issue with an incorrect test summary when a testcase name includes a colon (`issue #4508 `_) +* Fixed an issue when `extends `__ does not override options in the right order (`issue #4462 `_) 6.1.5 (2022-11-01) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/project/config.py b/platformio/project/config.py index 265fa95d..c4e08137 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -168,7 +168,7 @@ class ProjectConfigBase: yield (section, option) if self._parser.has_option(section, "extends"): extends_queue.extend( - self.parse_multi_values(self._parser.get(section, "extends"))[::-1] + self.parse_multi_values(self._parser.get(section, "extends")) ) def options(self, section=None, env=None): @@ -249,7 +249,9 @@ class ProjectConfigBase: return None def _traverse_for_value(self, section, option, option_meta=None): + # print("_traverse_for_value", section, option) for _section, _option in self.walk_options(section): + # print(13, _section, _option) if _option == option or ( option_meta and ( diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 964c0e67..6076a7d6 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -205,9 +205,9 @@ def test_options(config): assert config.options(env="test_extends") == [ "extends", "build_flags", + "monitor_speed", "lib_ldf_mode", "lib_compat_mode", - "monitor_speed", "custom_monitor_speed", "lib_deps", "lib_ignore", @@ -245,9 +245,9 @@ def test_sysenv_options(config): assert config.options(env="test_extends") == [ "extends", "build_flags", + "monitor_speed", "lib_ldf_mode", "lib_compat_mode", - "monitor_speed", "custom_monitor_speed", "lib_deps", "lib_ignore", @@ -427,9 +427,9 @@ def test_items(config): assert config.items(env="test_extends") == [ ("extends", ["strict_settings"]), ("build_flags", ["-D RELEASE"]), + ("monitor_speed", 115200), ("lib_ldf_mode", "chain+"), ("lib_compat_mode", "strict"), - ("monitor_speed", 115200), ("custom_monitor_speed", "115200"), ("lib_deps", ["Lib1", "Lib2"]), ("lib_ignore", ["LibIgnoreCustom"]), @@ -647,3 +647,24 @@ test_testing_command = config = ProjectConfig(str(project_conf)) testing_command = config.get("env:myenv", "test_testing_command") assert "$" not in " ".join(testing_command) + + +def test_extends_order(tmp_path: Path): + project_conf = tmp_path / "platformio.ini" + project_conf.write_text( + """ +[a] +board = test + +[b] +upload_tool = two + +[c] +upload_tool = three + +[env:native] +extends = a, b, c + """ + ) + config = ProjectConfig(str(project_conf)) + assert config.get("env:native", "upload_tool") == "three"