mirror of
https://github.com/esphome/esphome.git
synced 2026-08-25 23:56:19 +00:00
Store the native version floor as a Version and tidy the dependency skip
This commit is contained in:
@@ -160,9 +160,13 @@ def resolve_libraries(framework_path: Path) -> list[ArduinoLibrary]:
|
||||
# it cannot be resolved from the registry.
|
||||
for dep in normalize_dependencies(component.data.get("dependencies")):
|
||||
name = dep.get("name")
|
||||
if not name or dep.get("owner") or "version" in dep:
|
||||
continue
|
||||
if name in bundled_names:
|
||||
if (
|
||||
not name
|
||||
or dep.get("owner")
|
||||
or "version" in dep
|
||||
or name in bundled_names
|
||||
or is_lib_ignored(name, lib_ignore)
|
||||
):
|
||||
continue
|
||||
if not (framework_path / "libraries" / name).is_dir():
|
||||
# The shared converter skips version-less deps too, so this
|
||||
@@ -175,8 +179,6 @@ def resolve_libraries(framework_path: Path) -> list[ArduinoLibrary]:
|
||||
component.name,
|
||||
)
|
||||
continue
|
||||
if is_lib_ignored(name, lib_ignore):
|
||||
continue
|
||||
try:
|
||||
check_library_data(dep, ESP8266_PLATFORM, "arduino")
|
||||
except InvalidLibrary as err:
|
||||
|
||||
@@ -75,7 +75,7 @@ def get_arduino8266_tools_path() -> Path:
|
||||
|
||||
|
||||
# 3.1.1 rather than 3.1.0: the registry has no package for 3.1.0
|
||||
MIN_FRAMEWORK_VERSION = "3.1.1"
|
||||
MIN_FRAMEWORK_VERSION = cv.Version(3, 1, 1)
|
||||
|
||||
|
||||
def framework_package_version(ver: cv.Version) -> str:
|
||||
|
||||
@@ -133,7 +133,7 @@ def _validate_native_toolchain(config: ConfigType) -> ConfigType:
|
||||
|
||||
conf = config[CONF_FRAMEWORK]
|
||||
version = cv.Version.parse(conf[CONF_VERSION])
|
||||
if version < cv.Version.parse(MIN_FRAMEWORK_VERSION):
|
||||
if version < MIN_FRAMEWORK_VERSION:
|
||||
raise cv.Invalid(
|
||||
"'toolchain: arduino' requires framework version "
|
||||
f"{MIN_FRAMEWORK_VERSION} or newer"
|
||||
|
||||
@@ -27,8 +27,17 @@ def _arduino_toolchain() -> None:
|
||||
CORE.toolchain = Toolchain.ARDUINO
|
||||
|
||||
|
||||
def _config(board: str = "nodemcuv2", **framework: str) -> ConfigType:
|
||||
framework.setdefault(CONF_VERSION, "3.1.2")
|
||||
def _config(
|
||||
board: str = "nodemcuv2",
|
||||
version: str = "3.1.2",
|
||||
source: str | None = None,
|
||||
platform_version: str | None = None,
|
||||
) -> ConfigType:
|
||||
framework: dict[str, str] = {CONF_VERSION: version}
|
||||
if source is not None:
|
||||
framework[CONF_SOURCE] = source
|
||||
if platform_version is not None:
|
||||
framework[CONF_PLATFORM_VERSION] = platform_version
|
||||
# The real schema fills the source/platform_version defaults, so these
|
||||
# tests validate against what config validation actually emits
|
||||
return {
|
||||
@@ -44,24 +53,24 @@ def test_valid_config_passes() -> None:
|
||||
|
||||
def test_platformio_toolchain_skips_checks() -> None:
|
||||
CORE.toolchain = Toolchain.PLATFORMIO
|
||||
config = _config(board="not_a_board", **{CONF_VERSION: "2.7.4"})
|
||||
config = _config(board="not_a_board", version="2.7.4")
|
||||
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(**{CONF_VERSION: "3.1.0"}))
|
||||
_validate_native_toolchain(_config(version="3.1.0"))
|
||||
|
||||
|
||||
def test_version_at_floor_accepted() -> None:
|
||||
_validate_native_toolchain(_config(**{CONF_VERSION: "3.1.1"}))
|
||||
_validate_native_toolchain(_config(version="3.1.1"))
|
||||
|
||||
|
||||
def test_custom_platform_version_warns_and_is_dropped(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
config = _config(**{CONF_PLATFORM_VERSION: "platformio/espressif8266@4.0.1"})
|
||||
config = _config(platform_version="platformio/espressif8266@4.0.1")
|
||||
_validate_native_toolchain(config)
|
||||
assert "'platform_version' is ignored" in caplog.text
|
||||
assert CONF_PLATFORM_VERSION not in config[CONF_FRAMEWORK]
|
||||
@@ -79,7 +88,7 @@ def test_default_platform_version_does_not_warn(
|
||||
def test_custom_source_rejected() -> None:
|
||||
with pytest.raises(cv.Invalid, match="custom framework source"):
|
||||
_validate_native_toolchain(
|
||||
_config(**{CONF_SOURCE: "https://github.com/esp8266/Arduino.git"})
|
||||
_config(source="https://github.com/esp8266/Arduino.git")
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user