Parse only $PROJECT_HASH legacy built-in variable

This commit is contained in:
Ivan Kravets
2023-12-09 13:06:20 +02:00
parent 0f554d2f31
commit 204a60dd52
2 changed files with 6 additions and 6 deletions

View File

@ -316,10 +316,11 @@ class ProjectConfigBase:
return value return value
# legacy support for variables delclared without "${}" # legacy support for variables delclared without "${}"
legacy_vars = ["PROJECT_HASH"]
stop = False stop = False
while not stop: while not stop:
stop = True stop = True
for name in self.BUILTIN_VARS: for name in legacy_vars:
x = value.find(f"${name}") x = value.find(f"${name}")
if x < 0 or value[x - 1] == "$": if x < 0 or value[x - 1] == "$":
continue continue

View File

@ -354,10 +354,7 @@ def test_get_value(config):
"--help", "--help",
] ]
# test relative dir # test relative dir
assert config.get("platformio", "src_dir") == os.path.abspath( assert config.get("platformio", "src_dir") == "source"
os.path.join(os.getcwd(), "source")
)
# renamed option # renamed option
assert config.get("env:extra_1", "lib_install") == ["574"] assert config.get("env:extra_1", "lib_install") == ["574"]
assert config.get("env:extra_1", "lib_deps") == ["574"] assert config.get("env:extra_1", "lib_deps") == ["574"]
@ -654,6 +651,7 @@ def test_nested_interpolation(tmp_path: Path):
""" """
[platformio] [platformio]
build_dir = /tmp/pio-$PROJECT_HASH build_dir = /tmp/pio-$PROJECT_HASH
data_dir = $PROJECT_DIR/assets
[env:myenv] [env:myenv]
build_flags = -D UTIME=${UNIX_TIME} build_flags = -D UTIME=${UNIX_TIME}
@ -667,9 +665,10 @@ test_testing_command =
""" """
) )
config = ProjectConfig(str(project_conf)) config = ProjectConfig(str(project_conf))
assert config.get("platformio", "data_dir") == "$PROJECT_DIR/assets"
assert config.get("env:myenv", "build_flags")[0][-10:].isdigit()
testing_command = config.get("env:myenv", "test_testing_command") testing_command = config.get("env:myenv", "test_testing_command")
assert "$" not in " ".join(testing_command) assert "$" not in " ".join(testing_command)
assert config.get("env:myenv", "build_flags")[0][-10:].isdigit()
def test_extends_order(tmp_path: Path): def test_extends_order(tmp_path: Path):