diff --git a/esphome/espidf/size_summary.py b/esphome/espidf/size_summary.py index d860024b9c..8140e81699 100644 --- a/esphome/espidf/size_summary.py +++ b/esphome/espidf/size_summary.py @@ -55,8 +55,11 @@ def _find_app_partition_size(partitions_csv: Path) -> int | None: naive "prefer factory" rule would pick the wrong row. No qualifying row is legitimate absence (None); a build cannot succeed with a missing or malformed table (gen_esp32part consumes it first), so - those states belong to the backstop. + those states belong to the backstop -- the missing-file raise just + names that one cleanly. """ + if not partitions_csv.is_file(): + raise ValueError(f"partitions.csv not found at {partitions_csv}") for row in csv.reader(partitions_csv.read_text(encoding="utf-8").splitlines()): cells = [c.strip() for c in row] if not cells or cells[0].startswith("#") or len(cells) < 5: diff --git a/tests/unit_tests/test_size_summary.py b/tests/unit_tests/test_size_summary.py index 5aa3bb1fee..4728f6a2b3 100644 --- a/tests/unit_tests/test_size_summary.py +++ b/tests/unit_tests/test_size_summary.py @@ -328,3 +328,16 @@ def test_print_summary_bad_ram_region_still_prints_flash( out = capsys.readouterr().out assert "Flash:" in out and "RAM:" not in out assert "malformed memory_types" in caplog.text + + +def test_print_summary_missing_partitions_named_in_backstop( + tmp_path: Path, + capsys: pytest.CaptureFixture[str], + caplog: pytest.LogCaptureFixture, +) -> None: + """A vanished table is an impossible post-build state; the backstop + reports it by name instead of a bare FileNotFoundError.""" + size_json = _write_size_json(tmp_path, _dram_size_data()) + print_summary(size_json, tmp_path / "nope.csv") + assert "Flash:" not in capsys.readouterr().out + assert "partitions.csv not found" in caplog.text