Fixed an issue when extends does not override options in the right order // Resolve #4462

This commit is contained in:
Ivan Kravets
2023-01-14 19:40:53 +02:00
parent de4ba4cbe1
commit fb5e99473f
3 changed files with 28 additions and 4 deletions

View File

@ -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 <https://github.com/platformio/platformio-core/issues/4480>`_)
* Fixed an issue with an incorrect test summary when a testcase name includes a colon (`issue #4508 <https://github.com/platformio/platformio-core/issues/4508>`_)
* Fixed an issue when `extends <https://docs.platformio.org/en/latest/projectconf/sections/env/options/advanced/extends.html>`__ does not override options in the right order (`issue #4462 <https://github.com/platformio/platformio-core/issues/4462>`_)
6.1.5 (2022-11-01)
~~~~~~~~~~~~~~~~~~

View File

@ -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 (

View File

@ -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"