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.
This commit is contained in:
J. Nick Koston
2026-08-23 16:11:32 -05:00
parent b8f736ac86
commit 5447239258
2 changed files with 17 additions and 1 deletions
+4 -1
View File
@@ -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:
+13
View File
@@ -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