Dispatch esptool flashing via the backend hook, share the native trigger files, gate the probe, cache the closure

This commit is contained in:
J. Nick Koston
2026-08-22 21:21:25 -05:00
parent ff84e53ff1
commit cc73c0c67e
5 changed files with 76 additions and 53 deletions
@@ -86,7 +86,8 @@ def test_run_compile_success(tmp_path: Path) -> None:
with (
patch.object(framework, "check_and_install", return_value=_paths(tmp_path)),
patch.object(framework, "get_build_env", return_value={}),
patch("esphome.build_gen.arduino8266.write_project"),
# An unchanged manifest is what makes the -n probe run
patch("esphome.build_gen.arduino8266.write_project", return_value=False),
patch.object(
toolchain.subprocess,
"run",
@@ -118,7 +119,8 @@ def test_run_compile_noop_skips_the_build_spawn(tmp_path: Path) -> None:
with (
patch.object(framework, "check_and_install", return_value=_paths(tmp_path)),
patch.object(framework, "get_build_env", return_value={}),
patch("esphome.build_gen.arduino8266.write_project"),
# An unchanged manifest is what makes the -n probe run
patch("esphome.build_gen.arduino8266.write_project", return_value=False),
patch.object(
toolchain.subprocess,
"run",
@@ -145,7 +147,8 @@ def test_run_compile_surfaces_probe_diagnostics(
with (
patch.object(framework, "check_and_install", return_value=_paths(tmp_path)),
patch.object(framework, "get_build_env", return_value={}),
patch("esphome.build_gen.arduino8266.write_project"),
# An unchanged manifest is what makes the -n probe run
patch("esphome.build_gen.arduino8266.write_project", return_value=False),
patch.object(
toolchain.subprocess,
"run",
+8 -4
View File
@@ -7124,11 +7124,15 @@ def test_upload_using_esptool_arduino_toolchain(
tmp_path: Path,
mock_run_external_command_main: Mock,
) -> None:
"""The native ESP8266 Arduino toolchain flashes CORE.firmware_bin at 0x0."""
"""The native ESP8266 Arduino toolchain flashes its factory image at
0x0, dispatched through the platform's native_toolchain_module hook."""
setup_core(platform=PLATFORM_ESP8266, tmp_path=tmp_path, name="test")
CORE.toolchain = Toolchain.ARDUINO
CORE.firmware_bin.parent.mkdir(parents=True, exist_ok=True)
CORE.firmware_bin.touch()
from esphome.arduino8266 import toolchain as native
factory = native.get_factory_firmware_path()
factory.parent.mkdir(parents=True, exist_ok=True)
factory.touch()
config = {CONF_ESPHOME: {"platformio_options": {}}}
result = upload_using_esptool(config, "/dev/ttyUSB0", None, None)
@@ -7137,7 +7141,7 @@ def test_upload_using_esptool_arduino_toolchain(
cmd_list = list(mock_run_external_command_main.call_args[0][1:])
firmware_offset_idx = cmd_list.index("write-flash") + 4
assert cmd_list[firmware_offset_idx] == "0x0"
assert cmd_list[firmware_offset_idx + 1] == str(CORE.firmware_bin)
assert cmd_list[firmware_offset_idx + 1] == str(factory)
@pytest.mark.parametrize(