diff --git a/esphome/arduino8266/framework.py b/esphome/arduino8266/framework.py index 9172c95066..7a8b51e2be 100644 --- a/esphome/arduino8266/framework.py +++ b/esphome/arduino8266/framework.py @@ -18,7 +18,6 @@ toolchain has always used, so the bits are identical); the from __future__ import annotations -import functools import os from pathlib import Path from typing import NamedTuple @@ -155,9 +154,13 @@ def get_build_env(toolchain_path: Path) -> dict[str, str]: return env -@functools.cache def ccache_path() -> str | None: - """The ccache binary to prefix compiles with, or None when disabled.""" + """The ccache binary to prefix compiles with, or None when disabled. + + Deliberately uncached (matching espidf): the decision reads + ESPHOME_CCACHE_ENABLE and PATH, which can change between builds in a + long-lived host process. + """ return resolve_ccache_path() diff --git a/tests/unit_tests/test_arduino8266_framework.py b/tests/unit_tests/test_arduino8266_framework.py index 74a20c85fb..21bf756e6b 100644 --- a/tests/unit_tests/test_arduino8266_framework.py +++ b/tests/unit_tests/test_arduino8266_framework.py @@ -14,8 +14,7 @@ from esphome.core import CORE, EsphomeError @pytest.fixture(autouse=True) -def _clear_caches(tmp_path: Path) -> None: - framework.ccache_path.cache_clear() +def _build_path(tmp_path: Path) -> None: CORE.build_path = tmp_path @@ -100,18 +99,19 @@ def test_get_build_env_prepends_toolchain_bin(tmp_path: Path) -> None: assert env["CCACHE_DIR"] == "x" -def test_ccache_path_delegates_and_caches( +def test_ccache_path_delegates_uncached( monkeypatch: pytest.MonkeyPatch, ) -> None: """The wrapper delegates to the shared policy (covered in - build_helpers/test_ccache.py) and caches the result.""" + build_helpers/test_ccache.py) on every call: the env/PATH decision + must not freeze for the process lifetime in a long-lived host.""" monkeypatch.delenv("ESPHOME_CCACHE_ENABLE", raising=False) with patch.object( framework, "resolve_ccache_path", return_value="/usr/bin/ccache" ) as mock_resolve: assert framework.ccache_path() == "/usr/bin/ccache" assert framework.ccache_path() == "/usr/bin/ccache" - mock_resolve.assert_called_once() + assert mock_resolve.call_count == 2 def test_ccache_env(tmp_path: Path) -> None: