From ad40853283a66947c7bb19baa9a2a4f5805a9e93 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 28 Aug 2026 09:15:35 -0500 Subject: [PATCH] Pin the size command format in the template test, warn on schema drift --- esphome/espidf/size_summary.py | 4 +++- tests/unit_tests/build_gen/test_espidf.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/esphome/espidf/size_summary.py b/esphome/espidf/size_summary.py index b6d0782974..cab632defe 100644 --- a/esphome/espidf/size_summary.py +++ b/esphome/espidf/size_summary.py @@ -130,7 +130,9 @@ def print_summary(size_json: Path, partitions_csv: Path, firmware_elf: Path) -> if ram_total and ram_used is not None: print_size_line("RAM", ram_used, ram_total) else: - _LOGGER.debug("Skipping RAM summary: no DRAM/DIRAM region in %s", size_json) + # Every chip has a DRAM or DIRAM region, so this firing usually + # means the esp_idf_size json schema changed + _LOGGER.warning("Skipping RAM summary: no DRAM/DIRAM region in %s", size_json) # esp-idf-size >= 2.1 (IDF >= 6.0) reports the exact image size in # json2; older 1.x omits it, so derive the same figure from the ELF. diff --git a/tests/unit_tests/build_gen/test_espidf.py b/tests/unit_tests/build_gen/test_espidf.py index 079f10ddb9..2848d7202d 100644 --- a/tests/unit_tests/build_gen/test_espidf.py +++ b/tests/unit_tests/build_gen/test_espidf.py @@ -163,6 +163,18 @@ def test_has_discovered_components_after_configure(tmp_path: Path) -> None: assert has_discovered_components() +def test_get_project_cmakelists_size_command_uses_json2() -> None: + """The POST_BUILD size command uses the cheap json2 format, with --ng + only on the 1.x tool bundled with IDF < 6.""" + content = _render() + assert "-m esp_idf_size --ng --format=json2" in content + + CORE.data[KEY_ESP32][KEY_IDF_VERSION] = cv.Version(6, 0, 0) + content = _render() + assert "--ng" not in content + assert "--format=json2" in content + + def test_get_project_cmakelists_uses_supplied_builtin_components() -> None: """A cached list replaces project_description.json and is still filtered by EXCLUDE_COMPONENTS."""