mirror of
https://github.com/esphome/esphome.git
synced 2026-10-02 17:30:22 +00:00
Merge branch 'dev' into platformio-prefetch-git-clones
This commit is contained in:
@@ -13,6 +13,7 @@ from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from filelock import Timeout
|
||||
from platformio.dependencies import get_core_dependencies
|
||||
from platformio.package.manager._install import PackageManagerInstallMixin
|
||||
from platformio.package.manager.base import BasePackageManager
|
||||
from platformio.package.manager.library import LibraryPackageManager
|
||||
@@ -1825,30 +1826,31 @@ def test_preinstall_unlocks_even_when_pool_fails(tmp_path: Path) -> None:
|
||||
m.unlock.assert_called_once_with()
|
||||
|
||||
|
||||
def test_prefetch_skips_duplicate_tool_scons(tmp_path: Path) -> None:
|
||||
"""A platform that lists tool-scons itself does not get it appended."""
|
||||
def test_prefetch_replaces_platform_tool_scons_with_core_spec(tmp_path: Path) -> None:
|
||||
"""A platform's own tool-scons spec gives way to the core's registry spec."""
|
||||
_write_ini(tmp_path, "[env:testenv]\nplatform = fake/p@1\n")
|
||||
fake_platform = MagicMock()
|
||||
fake_platform.packages = {"tool-scons": {"optional": False}}
|
||||
fake_platform.get_package_spec.side_effect = lambda name: _FakeSpec(
|
||||
uri=None, name=name
|
||||
uri="https://x/scons.zip", name=name, owner=None
|
||||
)
|
||||
config = _fake_config(tmp_path, {"platform": "fake/p@1"})
|
||||
modules = _pio_modules(tmp_path, fake_platform, MagicMock(), config)
|
||||
batches: list[list[str]] = []
|
||||
batches: list[list] = []
|
||||
with (
|
||||
patch.dict("sys.modules", modules),
|
||||
patch.object(
|
||||
pf,
|
||||
"_registry_jobs",
|
||||
side_effect=lambda mgr, specs, seen: (
|
||||
batches.append([s.name for s in specs]) or ([], 0, [])
|
||||
batches.append(list(specs)) or ([], 0, [])
|
||||
),
|
||||
),
|
||||
patch.object(pf, "_uri_jobs", return_value=([], 0, [])),
|
||||
):
|
||||
pf._prefetch(tmp_path, "testenv")
|
||||
assert batches[0] == ["tool-scons"]
|
||||
(spec,) = batches[0]
|
||||
assert (spec.name, spec.owner, spec.uri) == ("tool-scons", "platformio", None)
|
||||
|
||||
|
||||
def test_platformio_private_api_contract() -> None:
|
||||
@@ -1881,6 +1883,8 @@ def test_platformio_private_api_contract() -> None:
|
||||
assert callable(getattr(BasePackageManager, name))
|
||||
# The dependency wave mirrors install_dependency's builtin skip
|
||||
assert callable(LibraryPackageManager.is_builtin_lib)
|
||||
# The prefetch keys tool-scons on this core dependency
|
||||
assert "tool-scons" in get_core_dependencies()
|
||||
# The pre-install passes these positionally / by keyword
|
||||
assert "compatibility" in inspect.signature(BasePackageManager.__init__).parameters
|
||||
lib_params = inspect.signature(LibraryPackageManager.__init__).parameters
|
||||
|
||||
Reference in New Issue
Block a user