mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 16:30:22 +00:00
Re-glue spaced -D tokens so knob defines are detected like PlatformIO
This commit is contained in:
@@ -665,3 +665,11 @@ def test_write_project_empty_core_raises(tmp_path: Path) -> None:
|
||||
pytest.raises(EsphomeError, match="no core sources"),
|
||||
):
|
||||
arduino8266.write_project(paths)
|
||||
|
||||
|
||||
def test_flag_defines_joins_spaced_define() -> None:
|
||||
"""A spaced "-D KNOB" entry is detected exactly as PlatformIO detects it."""
|
||||
_set_flags("-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH")
|
||||
defines = _flag_defines()
|
||||
assert "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH" in defines
|
||||
assert "" not in defines
|
||||
|
||||
@@ -538,5 +538,9 @@ def test_split_flag_entry_unbalanced_quote_is_clean() -> None:
|
||||
from esphome.platformio.library import split_flag_entry
|
||||
|
||||
assert split_flag_entry('-DX="a b"', "library x") == ["-DX=a b"]
|
||||
# join_flag_args re-glues a spaced -D like ParseFlags does
|
||||
from esphome.platformio.library import join_flag_args
|
||||
|
||||
assert join_flag_args(["-D", "FOO=1", "-Os"], "x") == ["-DFOO=1", "-Os"]
|
||||
with pytest.raises(EsphomeError, match=r"Malformed build flag.*library x"):
|
||||
split_flag_entry('-DX="unclosed', "library x")
|
||||
|
||||
Reference in New Issue
Block a user