diff --git a/esphome/platformio/library.py b/esphome/platformio/library.py index 9635236d8e..e0c9d8c1f4 100644 --- a/esphome/platformio/library.py +++ b/esphome/platformio/library.py @@ -978,10 +978,12 @@ def _prefetch_wave( # A warm build must stay silent continue components.append(component) - if len(components) < 2: + if not components: return + # Single-item waves (a dependency chain discovers one archive per + # wave) go through the same runner: one download method, one bar _LOGGER.info( - "Downloading %d libraries: %s", + "Downloading %d library archive(s): %s", len(components), ", ".join(c.name for c in components), ) diff --git a/tests/unit_tests/test_platformio_library.py b/tests/unit_tests/test_platformio_library.py index a4aa79b584..d4bb52bac6 100644 --- a/tests/unit_tests/test_platformio_library.py +++ b/tests/unit_tests/test_platformio_library.py @@ -766,16 +766,18 @@ def test_prefetch_wave_warm_cache_is_silent( assert "Downloading" not in caplog.text -def test_prefetch_wave_single_archive_skips_the_pool( - monkeypatch: pytest.MonkeyPatch, +def test_prefetch_wave_single_archive_uses_the_batch( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture ) -> None: - """One archive gains nothing from a pool; the sequential call keeps its - progress bar.""" + """A dependency chain discovers one archive per wave; it downloads + through the same runner so there is one download method and one bar.""" + caplog.set_level("INFO") + calls: list[str] = [] monkeypatch.setattr( URLSource, "download", - lambda self, dir_suffix, **kw: (_ for _ in ()).throw( - AssertionError("prefetched") + lambda self, dir_suffix, force=False, salt="", namespace="", progress=None: ( + calls.append(self.url) ), ) lib._prefetch_wave( @@ -783,6 +785,8 @@ def test_prefetch_wave_single_archive_skips_the_pool( "", "idf", ) + assert calls == ["https://x/a.tar.gz"] + assert "Downloading 1 library archive(s): a" in caplog.text def test_normalize_dependencies_forms(caplog) -> None: