mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 16:30:22 +00:00
Merge branch 'esp8266-native-ninja-emission' into esp8266-arduino-toolchain
This commit is contained in:
@@ -1158,6 +1158,16 @@ def test_esp_idf_infra_changed(changed_files: list[str], expected: bool) -> None
|
||||
assert determine_jobs._esp_idf_infra_changed(changed_files) is expected
|
||||
|
||||
|
||||
def test_esp_idf_infra_trigger_paths_exist() -> None:
|
||||
"""A renamed or moved trigger module must fail here, not silently stop
|
||||
forcing the esp32 IDF compile."""
|
||||
repo_root = Path(__file__).resolve().parents[2]
|
||||
for file in determine_jobs.ESP_IDF_INFRA_TRIGGER_FILES:
|
||||
assert (repo_root / file).is_file(), f"trigger file {file} moved or renamed"
|
||||
for prefix in determine_jobs.ESP_IDF_INFRA_TRIGGER_PATH_PREFIXES:
|
||||
assert (repo_root / prefix).is_dir(), f"trigger dir {prefix} moved or renamed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("changed_files", "expected_result"),
|
||||
[
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user