Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission

This commit is contained in:
J. Nick Koston
2026-08-23 10:48:54 -05:00
7 changed files with 80 additions and 20 deletions
@@ -394,16 +394,16 @@ def test_parse_entry_recovers_from_unconfigured_launcher(
assert "Stripping unconfigured launcher" in caplog.text
def test_parse_entry_keeps_launcher_without_program() -> None:
"""A launcher followed only by flags (no program to recover) stays as
token zero; the cache layer refuses to persist it."""
def test_parse_entry_rejects_launcher_without_program() -> None:
"""A launcher followed only by flags is rejected in the parser itself,
so no caller can record ccache as the compiler."""
entry = _entry(
f"{ABS}build",
f"{ABS}build/src/esphome/core/application.cpp",
"/opt/homebrew/bin/ccache -c a.cpp -o a.o",
)
cxx_path, _, _, _ = idedata.parse_entry(entry)
assert cxx_path == "/opt/homebrew/bin/ccache"
with pytest.raises(EsphomeError, match="compile database is unusable"):
idedata.parse_entry(entry)
def _write_compile_commands(tmp_path: Path) -> Path:
@@ -623,7 +623,7 @@ def test_load_or_build_idedata_cache_hit_restamps_prog_path(tmp_path: Path) -> N
def test_idedata_from_build_non_list_compile_db_raises(tmp_path: Path) -> None:
"""Valid JSON that is not a list raises by name, inside the best-effort tuple."""
compile_commands = tmp_path / "compile_commands.json"
for bad in ("{}", "null", '"text"'):
for bad in ("{}", "null", '"text"', '["a", "b"]', "[1, 2]"):
compile_commands.write_text(bad)
with pytest.raises(EsphomeError, match="not a compile-command list"):
idedata.idedata_from_build(compile_commands)
@@ -7,9 +7,11 @@ import pytest
from esphome.build_helpers.size_summary import format_bar, print_size_line
def test_format_bar_zero_total() -> None:
"""A zero total must not divide by zero."""
assert format_bar(0, 0) == "[ ] 0.0% (used 0 bytes from 0 bytes)"
def test_format_bar_non_positive_total_raises() -> None:
"""A meaningless "from 0 bytes" bar raises so every caller must skip it."""
for total in (0, -1):
with pytest.raises(ValueError, match="non-positive size total"):
format_bar(0, total)
def test_print_size_line_label_padding(capsys: pytest.CaptureFixture[str]) -> None:
+32 -2
View File
@@ -237,9 +237,39 @@ def test_print_summary_blank_partition_size_warns(tmp_path, caplog) -> None:
),
ids=("non-dict-memory-types", "scalar-region", "non-numeric-sizes"),
)
def test_print_summary_nested_shapes_never_raise(tmp_path, caplog, payload) -> None:
"""The blanket guard keeps unexpected nested shapes from raising."""
def test_print_summary_nested_shapes_skip_ram_by_name(
tmp_path, caplog, payload
) -> None:
"""Malformed RAM shapes hit the named guard, not the blanket backstop."""
size_json = tmp_path / "size.json"
size_json.write_text(payload)
print_summary(size_json, tmp_path / "partitions.csv")
assert "Skipping RAM summary" in caplog.text
def test_print_summary_bad_ram_region_still_prints_flash(
tmp_path, caplog, capsys
) -> None:
"""A malformed RAM region cannot suppress a computable Flash line."""
size_json = tmp_path / "size.json"
size_json.write_text(
'{"memory_types": {"DRAM": {"used": "x", "size": "y"}}, "image_size": 100}'
)
partitions = tmp_path / "partitions.csv"
partitions.write_text("app0, app, ota_0, 0x10000, 0x100000,\n")
print_summary(size_json, partitions)
assert "Skipping RAM summary" in caplog.text
assert "Flash:" in capsys.readouterr().out
def test_print_summary_blanket_guard_never_raises(tmp_path, caplog) -> None:
"""Shapes the named guards miss (non-numeric image_size) warn via the
blanket backstop instead of raising past a linked build."""
size_json = tmp_path / "size.json"
size_json.write_text(
'{"memory_types": {"DRAM": {"used": 1, "size": 2}}, "image_size": "x"}'
)
partitions = tmp_path / "partitions.csv"
partitions.write_text("app0, app, ota_0, 0x10000, 0x100000,\n")
print_summary(size_json, partitions)
assert "Skipping size summary" in caplog.text