From 54472392581e2baad16b00cb47fd15b74efca73c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 23 Aug 2026 16:11:32 -0500 Subject: [PATCH] Name the missing-table state for the backstop Still the backstop's business, but a clean message beats a bare FileNotFoundError for the one impossible state most likely to appear in a report. --- esphome/espidf/size_summary.py | 5 ++++- tests/unit_tests/test_size_summary.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/esphome/espidf/size_summary.py b/esphome/espidf/size_summary.py index f01a2ee5e4..d6006a188c 100644 --- a/esphome/espidf/size_summary.py +++ b/esphome/espidf/size_summary.py @@ -53,8 +53,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 5ed81b1fae..23365704b7 100644 --- a/tests/unit_tests/test_size_summary.py +++ b/tests/unit_tests/test_size_summary.py @@ -305,3 +305,16 @@ def test_print_summary_corrupt_size_json_warns( print_summary(size_json, None) assert capsys.readouterr().out == "" assert "Skipping size summary" 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