[espidf] Resolve the ESP-IDF tool paths once per build (#19996)

This commit is contained in:
J. Nick Koston
2026-10-01 19:39:06 -05:00
committed by GitHub
parent b324a7c6e0
commit ff97353767
2 changed files with 55 additions and 2 deletions
+24
View File
@@ -1511,6 +1511,30 @@ def test_get_idf_tool_paths_raises_on_failure(tmp_path: Path) -> None:
_get_idf_tool_paths(tmp_path)
def test_get_idf_tool_paths_runs_the_script_once_per_build(tmp_path: Path) -> None:
payload = json.dumps({"paths_to_export": ["/a"], "export_vars": {"X": "1"}})
env = {"IDF_TOOLS_PATH": str(tmp_path / "tools")}
with patch(
"esphome.espidf.framework.run_command", return_value=(True, payload, "")
) as run:
first = _get_idf_tool_paths(tmp_path, env)
second = _get_idf_tool_paths(tmp_path, env)
assert run.call_count == 1
assert first == second == (["/a"], {"X": "1"})
def test_get_idf_tool_paths_does_not_cache_a_failure(tmp_path: Path) -> None:
payload = json.dumps({"paths_to_export": ["/a"], "export_vars": {}})
with patch(
"esphome.espidf.framework.run_command",
side_effect=[(False, "", "err"), (True, payload, "")],
) as run:
with pytest.raises(RuntimeError, match="Can't get ESP-IDF tool paths"):
_get_idf_tool_paths(tmp_path)
assert _get_idf_tool_paths(tmp_path) == (["/a"], {})
assert run.call_count == 2
def test_get_python_version_parses_stdout(tmp_path: Path) -> None:
with patch(
"esphome.espidf.framework.run_command", return_value=(True, "3.11.0\n", "")