mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 11:26:39 +00:00
Gate only the cache read on an explicit CLI toolchain, keep the refresh
The upload/logs cache split: an explicit --toolchain still skips the read and runs the per-platform validators, but the freshly validated config is saved again so a later plain run keeps the fast path (the sidecar records the resolved toolchain). check_supported_toolchain is module-private now since it has no caller outside config_validation, and require_platformio_toolchain's docstring describes what actually happens when another platform's toolchain is passed.
This commit is contained in:
@@ -7247,3 +7247,27 @@ def test_cli_toolchain_skips_the_validated_config_cache(tmp_path: Path) -> None:
|
||||
assert run_esphome(argv) == 2
|
||||
mock_cache.assert_not_called()
|
||||
mock_read.assert_called_once()
|
||||
|
||||
|
||||
def test_cli_toolchain_still_refreshes_the_validated_config_cache(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""An explicit --toolchain gates only the cache read; the freshly
|
||||
validated config is still saved, and its sidecar records the resolved
|
||||
toolchain for a later plain run."""
|
||||
from esphome.__main__ import run_esphome
|
||||
|
||||
conf = tmp_path / "device.yaml"
|
||||
conf.write_text("esphome:\n name: t\n")
|
||||
argv = ["esphome", "--toolchain", "platformio", "logs", str(conf)]
|
||||
with (
|
||||
patch("esphome.compiled_config.load_compiled_config") as mock_load,
|
||||
patch("esphome.config.read_config", return_value={CONF_ESPHOME: {}}),
|
||||
patch("esphome.compiled_config.save_compiled_config_and_sidecar") as mock_save,
|
||||
patch.dict(
|
||||
"esphome.__main__.POST_CONFIG_ACTIONS", {"logs": Mock(return_value=0)}
|
||||
),
|
||||
):
|
||||
assert run_esphome(argv) == 0
|
||||
mock_load.assert_not_called()
|
||||
mock_save.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user