mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Fix issue with nested interpolation
This commit is contained in:
@ -300,7 +300,7 @@ class ProjectConfigBase(object):
|
|||||||
return parent_section[4:]
|
return parent_section[4:]
|
||||||
# handle nested calls
|
# handle nested calls
|
||||||
try:
|
try:
|
||||||
value = self.getraw(section, option)
|
value = self.get(section, option)
|
||||||
except RecursionError:
|
except RecursionError:
|
||||||
raise exception.ProjectOptionValueError(
|
raise exception.ProjectOptionValueError(
|
||||||
"Infinite recursion has been detected", option, section
|
"Infinite recursion has been detected", option, section
|
||||||
|
@ -343,6 +343,7 @@ def test_get_value(config):
|
|||||||
assert config.get("platformio", "src_dir") == os.path.abspath(
|
assert config.get("platformio", "src_dir") == os.path.abspath(
|
||||||
os.path.join(os.getcwd(), "source")
|
os.path.join(os.getcwd(), "source")
|
||||||
)
|
)
|
||||||
|
assert "$PROJECT_HASH" not in config.get("platformio", "build_dir")
|
||||||
|
|
||||||
|
|
||||||
def test_items(config):
|
def test_items(config):
|
||||||
@ -597,3 +598,25 @@ custom_option = ${this.board}
|
|||||||
config = ProjectConfig(str(project_conf))
|
config = ProjectConfig(str(project_conf))
|
||||||
assert config.get("env:myenv", "custom_option") == "uno"
|
assert config.get("env:myenv", "custom_option") == "uno"
|
||||||
assert config.get("env:myenv", "build_flags") == ["-Dmyenv"]
|
assert config.get("env:myenv", "build_flags") == ["-Dmyenv"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_nested_interpolation(tmp_path: Path):
|
||||||
|
project_conf = tmp_path / "platformio.ini"
|
||||||
|
project_conf.write_text(
|
||||||
|
"""
|
||||||
|
[platformio]
|
||||||
|
build_dir = ~/tmp/pio-$PROJECT_HASH
|
||||||
|
|
||||||
|
[env:myenv]
|
||||||
|
test_testing_command =
|
||||||
|
${platformio.packages_dir}/tool-simavr/bin/simavr
|
||||||
|
-m
|
||||||
|
atmega328p
|
||||||
|
-f
|
||||||
|
16000000L
|
||||||
|
${platformio.build_dir}/${this.__env__}/firmware.elf
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
config = ProjectConfig(str(project_conf))
|
||||||
|
testing_command = config.get("env:myenv", "test_testing_command")
|
||||||
|
assert "$" not in " ".join(testing_command)
|
||||||
|
Reference in New Issue
Block a user