diff --git a/esphome/platformio/library.py b/esphome/platformio/library.py index 9840e907bf..a6bb8a1715 100644 --- a/esphome/platformio/library.py +++ b/esphome/platformio/library.py @@ -923,10 +923,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 140f8bb169..d24eae6ec6 100644 --- a/tests/unit_tests/test_platformio_library.py +++ b/tests/unit_tests/test_platformio_library.py @@ -762,16 +762,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( @@ -779,6 +781,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: