mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 00:10:22 +00:00
Merge branch 'esp8266-native-build-infra' into esp8266-native-framework-installer
# Conflicts: # esphome/components/nrf52/framework.py # esphome/espidf/framework.py # esphome/framework_helpers.py # esphome/platformio/toolchain.py
This commit is contained in:
@@ -451,3 +451,17 @@ def test_load_or_build_idedata_never_caches_bad_compiler(tmp_path: Path) -> None
|
||||
)
|
||||
assert data["cxx_path"] == "/usr/bin/python3"
|
||||
assert not cache.exists()
|
||||
|
||||
|
||||
def test_load_or_build_idedata_cache_hit_skips_rebuild(tmp_path: Path) -> None:
|
||||
"""A valid cache newer than the compile DB is served without re-parsing."""
|
||||
compile_commands = _write_compile_commands(tmp_path)
|
||||
cache = tmp_path / "c.json"
|
||||
cache.write_text(json.dumps({"cc_path": "/tools/gcc", "cached": True}))
|
||||
os.utime(cache, (compile_commands.stat().st_mtime + 5,) * 2)
|
||||
with patch.object(idedata, "idedata_from_build") as mock_build:
|
||||
data = idedata.load_or_build_idedata(
|
||||
compile_commands, tmp_path / "f.elf", cache
|
||||
)
|
||||
mock_build.assert_not_called()
|
||||
assert data["cached"] is True
|
||||
|
||||
@@ -49,7 +49,8 @@ def test_relocate_ratetable_inserts_after_data_start() -> None:
|
||||
patched = relocate_ratetable(_COMMON_LD_SNIPPET)
|
||||
assert RATETABLE_RULE in patched
|
||||
# Inserted after the .data section's anchor, not the .dport0.data one
|
||||
assert patched.index("_data_start = ABSOLUTE(.);") < patched.index(RATETABLE_RULE)
|
||||
# (whose closing brace bounds the decoy block)
|
||||
assert RATETABLE_RULE not in patched[: patched.index("} >dport0_0_seg")]
|
||||
assert patched.index(RATETABLE_RULE) < patched.index("*(.data)")
|
||||
# Idempotent on an already-patched script
|
||||
assert relocate_ratetable(patched) == patched
|
||||
@@ -106,14 +107,20 @@ def test_board_build_covers_every_board() -> None:
|
||||
assert set(BOARDS) <= set(ESP8266_BOARD_BUILD)
|
||||
|
||||
|
||||
def test_surgery_fingerprint_tracks_inputs() -> None:
|
||||
"""The fingerprint changes with any behavioral input, so linker-script
|
||||
caches stamped with it self-invalidate on surgery edits."""
|
||||
from unittest.mock import patch
|
||||
def test_surgery_fingerprint_covers_module_source() -> None:
|
||||
"""The fingerprint hashes the module source, so any surgery edit
|
||||
invalidates linker-script caches stamped with it."""
|
||||
import hashlib
|
||||
import inspect
|
||||
|
||||
from esphome.components.esp8266 import build_surgery
|
||||
|
||||
base = build_surgery.surgery_fingerprint()
|
||||
assert base == build_surgery.surgery_fingerprint()
|
||||
with patch.object(build_surgery, "_TESTING_SEGMENT_SIZES", {"iram1_0_seg": "0x1"}):
|
||||
assert build_surgery.surgery_fingerprint() != base
|
||||
expected = hashlib.sha256(inspect.getsource(build_surgery).encode()).hexdigest()
|
||||
assert build_surgery.surgery_fingerprint() == expected
|
||||
|
||||
|
||||
def test_testing_memory_patches_present_but_unselected_raises() -> None:
|
||||
"""A known segment left off the caller's list must fail, not silently
|
||||
keep its real memory limit."""
|
||||
with pytest.raises(RuntimeError, match="not selected"):
|
||||
apply_testing_memory_patches(_FLASH_LD_SNIPPET, ("dram0_0_seg",))
|
||||
|
||||
Reference in New Issue
Block a user