mirror of
https://github.com/esphome/esphome.git
synced 2026-09-28 15:30:21 +00:00
Merge branch 'esp8266-native-framework-installer' into esp8266-native-library-backend
This commit is contained in:
@@ -428,6 +428,27 @@ def test_load_or_build_idedata_corrupted_cache_is_logged(
|
||||
assert "Discarding unreadable idedata cache" in caplog.text
|
||||
|
||||
|
||||
def test_load_or_build_idedata_discards_unreadable_cache_file(
|
||||
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""An OSError on the cache read (permissions, I/O) regenerates like a
|
||||
parse failure instead of aborting the consumer."""
|
||||
compile_commands = _write_compile_commands(tmp_path)
|
||||
cache = tmp_path / "c.json"
|
||||
cache.write_text("{}")
|
||||
cache.chmod(0)
|
||||
os.utime(cache, (compile_commands.stat().st_mtime + 5,) * 2)
|
||||
try:
|
||||
with patch.object(idedata, "get_toolchain_includes", return_value=[]):
|
||||
data = idedata.load_or_build_idedata(
|
||||
compile_commands, tmp_path / "f.elf", cache
|
||||
)
|
||||
finally:
|
||||
cache.chmod(0o600)
|
||||
assert data["cxx_path"] == "/tools/g++"
|
||||
assert "Discarding unreadable idedata cache" in caplog.text
|
||||
|
||||
|
||||
def test_load_or_build_idedata_never_caches_a_launcher(tmp_path: Path) -> None:
|
||||
"""A compile DB naming a launcher as the compiler is rejected, never cached."""
|
||||
compile_commands = tmp_path / "compile_commands.json"
|
||||
|
||||
@@ -631,7 +631,7 @@ def test_lex_build_flags_dangling_flag_does_not_cross_entries(
|
||||
|
||||
|
||||
def test_prefetch_wave_downloads_registry_archives_in_parallel(
|
||||
setup_core, monkeypatch: pytest.MonkeyPatch
|
||||
setup_core, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Registry archives in one wave download concurrently, deduped by URL;
|
||||
git/local sources and failures are left to the sequential call."""
|
||||
@@ -661,10 +661,12 @@ def test_prefetch_wave_downloads_registry_archives_in_parallel(
|
||||
"https://x/b.tar.gz",
|
||||
"https://x/boom.tar.gz",
|
||||
]
|
||||
# The failure surfaces at default verbosity, after the bar
|
||||
assert "Prefetch of c failed (retrying sequentially)" in caplog.text
|
||||
|
||||
|
||||
def test_prefetch_wave_unknown_size_falls_back_to_sequential(
|
||||
setup_core, monkeypatch: pytest.MonkeyPatch
|
||||
setup_core, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Any unknown HEAD size skips the parallel prefetch entirely so the
|
||||
sequential downloads keep their per-file bars."""
|
||||
@@ -678,7 +680,10 @@ def test_prefetch_wave_unknown_size_falls_back_to_sequential(
|
||||
("a", ConvertedLibrary("a", "1.0", URLSource("https://x/a.tar.gz"))),
|
||||
("b", ConvertedLibrary("b", "1.0", URLSource("https://x/b.tar.gz"))),
|
||||
]
|
||||
caplog.set_level("DEBUG")
|
||||
lib._prefetch_wave(wave, "", "idf")
|
||||
# The culprit URL is named so the fallback is traceable
|
||||
assert "No Content-Length for https://x/b.tar.gz" in caplog.text
|
||||
|
||||
|
||||
def test_content_lengths_head_requests(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
|
||||
@@ -2506,6 +2506,9 @@ def test_build_info_stale_branches(tmp_path: Path) -> None:
|
||||
assert _build_info_stale(h, cpp, info, 1) is True # JSON unreadable
|
||||
info.write_text("not json")
|
||||
assert _build_info_stale(h, cpp, info, 1) is True
|
||||
# Valid JSON that is not an object is stale, not an AttributeError
|
||||
info.write_text("[]")
|
||||
assert _build_info_stale(h, cpp, info, 1) is True
|
||||
info.write_text(json_mod.dumps({"config_hash": 2, "esphome_version": __version__}))
|
||||
assert _build_info_stale(h, cpp, info, 1) is True # hash mismatch
|
||||
info.write_text(json_mod.dumps({"config_hash": 1, "esphome_version": "0.0.0"}))
|
||||
|
||||
Reference in New Issue
Block a user