mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 17:00:21 +00:00
Extract the shared native-build helpers from the ESP-IDF backend
This commit is contained in:
@@ -126,3 +126,33 @@ def test_print_summary_handles_no_memory_types(
|
||||
size_json = _write_size_json(tmp_path, {"image_size": 0})
|
||||
print_summary(size_json, partitions_csv=None)
|
||||
assert capsys.readouterr().out == ""
|
||||
|
||||
|
||||
def test_format_bar_zero_total() -> None:
|
||||
"""A zero total must not divide by zero."""
|
||||
from esphome.espidf.size_summary import format_bar
|
||||
|
||||
assert format_bar(0, 0) == "[ ] 0.0% (used 0 bytes from 0 bytes)"
|
||||
|
||||
|
||||
def test_print_summary_flash_line(
|
||||
tmp_path: Path, capsys: pytest.CaptureFixture[str]
|
||||
) -> None:
|
||||
"""image_size + a factory app partition produce the Flash line."""
|
||||
size_json = tmp_path / "esp_idf_size.json"
|
||||
size_json.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"memory_types": {"DRAM": {"used": 100, "size": 200}},
|
||||
"image_size": 500,
|
||||
}
|
||||
)
|
||||
)
|
||||
partitions = tmp_path / "partitions.csv"
|
||||
partitions.write_text(
|
||||
"# name, type, subtype, offset, size\napp0, app, factory, 0x10000, 0x100000\n"
|
||||
)
|
||||
print_summary(size_json, partitions)
|
||||
out = capsys.readouterr().out
|
||||
assert "RAM: [===== ] 50.0% (used 100 bytes from 200 bytes)" in out
|
||||
assert "Flash: [ ] 0.0% (used 500 bytes from 1048576 bytes)" in out
|
||||
|
||||
Reference in New Issue
Block a user