From 91eed262c8fbbb536d715fb78e35618ca4800b9a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 20 Aug 2026 20:46:15 -0500 Subject: [PATCH] Repr zero-arg script exceptions, surface a None idedata after an IDF build --- esphome/__main__.py | 3 ++- esphome/platformio/extra_script.py | 2 +- tests/unit_tests/test_main.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index f1b0fb7592..f510e6dcff 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -856,7 +856,8 @@ def compile_program(args: ArgsProtocol, config: ConfigType) -> int: toolchain.create_ota_bin() toolchain.create_elf_copy() try: - toolchain.get_idedata() + if toolchain.get_idedata() is None: + _LOGGER.warning("No idedata was generated for this build") except (EsphomeError, OSError, RuntimeError, ValueError) as err: # The firmware already built; idedata is a bonus artifact here. # Broad on purpose: a vanished compiler (OSError), a failed diff --git a/esphome/platformio/extra_script.py b/esphome/platformio/extra_script.py index 6474f4ce06..4f6a7df29f 100644 --- a/esphome/platformio/extra_script.py +++ b/esphome/platformio/extra_script.py @@ -214,7 +214,7 @@ def run_extra_script( # build could produce wrong-output firmware that links cleanly. The # warning plus the resulting loud link error point back here. _LOGGER.warning( - "PIO extra-script %s (in %s) raised %s; ignoring its output", + "PIO extra-script %s (in %s) raised %r; ignoring its output", script_path, library_dir.name, e, diff --git a/tests/unit_tests/test_main.py b/tests/unit_tests/test_main.py index b6a6e300c4..a398e8d63a 100644 --- a/tests/unit_tests/test_main.py +++ b/tests/unit_tests/test_main.py @@ -7171,3 +7171,32 @@ def test_compile_program_espidf_idedata_failure_does_not_fail_build( ): assert compile_program(MagicMock(), {}) == 0 assert "Could not generate idedata" in caplog.text + + +def test_compile_program_espidf_idedata_none_warns( + caplog: pytest.LogCaptureFixture, +) -> None: + """A silent None from the post-compile idedata refresh is made visible.""" + from esphome.const import ( + KEY_CORE, + KEY_TARGET_FRAMEWORK, + KEY_TARGET_PLATFORM, + Toolchain, + ) + from esphome.core import CORE + + CORE.toolchain = Toolchain.ESP_IDF + CORE.data[KEY_CORE] = { + KEY_TARGET_PLATFORM: "esp32", + KEY_TARGET_FRAMEWORK: "esp-idf", + } + with ( + patch("esphome.espidf.toolchain.run_compile", return_value=0), + patch("esphome.espidf.toolchain.create_factory_bin"), + patch("esphome.espidf.toolchain.create_ota_bin"), + patch("esphome.espidf.toolchain.create_elf_copy"), + patch("esphome.espidf.toolchain.get_idedata", return_value=None), + patch("esphome.__main__._check_and_emit_build_info"), + ): + assert compile_program(MagicMock(), {}) == 0 + assert "No idedata was generated" in caplog.text