[esp8266] Use our own Arduino core builds for the native toolchain (#19876)

This commit is contained in:
J. Nick Koston
2026-09-29 18:38:51 +02:00
committed by GitHub
parent 5be41dec15
commit a7e0afeb46
6 changed files with 152 additions and 99 deletions
@@ -2,9 +2,14 @@
import pytest
from esphome.components.esp8266 import _arduino_check_versions
from esphome.components.esp8266 import (
_arduino_check_versions,
_format_framework_arduino_version,
_framework_package_version,
)
import esphome.config_validation as cv
from esphome.const import CONF_PLATFORM_VERSION, CONF_VERSION
from esphome.core import EsphomeError
def test_versions_before_3_are_rejected() -> None:
@@ -21,3 +26,27 @@ def test_supported_versions_pass() -> None:
value = _arduino_check_versions({CONF_VERSION: "recommended"})
assert value[CONF_VERSION] == "3.1.2"
assert "espressif8266@4.2.1" in value[CONF_PLATFORM_VERSION]
def test_framework_package_version() -> None:
assert _framework_package_version(cv.Version(3, 1, 2)) == "3.30102.0"
assert _framework_package_version(cv.Version(3, 2, 0)) == "3.30200.0"
# A future major bump needs its own encoding, not a doomed registry lookup
with pytest.raises(EsphomeError, match="not supported yet"):
_framework_package_version(cv.Version(4, 0, 0))
# Cores before 3.x cannot build ESPHome (C++20) and are rejected
with pytest.raises(EsphomeError, match="requires core 3"):
_framework_package_version(cv.Version(2, 7, 4))
def test_format_framework_arduino_version_pins_all_series() -> None:
"""The PlatformIO source formatter across every encoding era."""
assert _format_framework_arduino_version(cv.Version(3, 1, 2)) == "~3.30102.0"
# Pre-3 cores are rejected with the version line anchored
with pytest.raises(cv.Invalid, match="requires core 3"):
_format_framework_arduino_version(cv.Version(2, 7, 4))
# Anchored to the framework version line, not a bare EsphomeError
with pytest.raises(cv.Invalid, match="not supported yet") as excinfo:
_format_framework_arduino_version(cv.Version(4, 0, 0))
assert excinfo.value.path == ["version"]
@@ -67,21 +67,24 @@ def test_valid_config_passes() -> None:
def test_platformio_toolchain_skips_checks() -> None:
# 3.0.2 is pio-legal (>= the global 3.0.0 floor) but below the native
# toolchain's own 3.1.1 floor; the bogus board only the native path checks
# 3.0.2 is pio-legal (>= the global 3.0.0 floor) but has no native build;
# the bogus board only the native path checks
CORE.toolchain = Toolchain.PLATFORMIO
config = _config(board="not_a_board", version="3.0.2")
assert _validate_native_toolchain(config) is config
def test_version_below_floor_rejected() -> None:
# 3.1.0 has no registry package, so the native floor is 3.1.1
with pytest.raises(cv.Invalid, match="3.1.1 or newer"):
_validate_native_toolchain(_config(version="3.1.0"))
def test_version_without_build_rejected() -> None:
"""Only the core versions built in esphome-libs/arduino-esp8266 work."""
with pytest.raises(
cv.Invalid, match=r"3\.1\.1.*available: 3\.1\.2.*platformio"
) as excinfo:
_validate_native_toolchain(_config(version="3.1.1"))
assert excinfo.value.path == [CONF_FRAMEWORK, CONF_VERSION]
def test_version_at_floor_accepted() -> None:
_validate_native_toolchain(_config(version="3.1.1"))
def test_built_version_accepted() -> None:
_validate_native_toolchain(_config(version="3.1.2"))
def test_custom_platform_version_warns_and_is_dropped(