mirror of
https://github.com/esphome/esphome.git
synced 2026-10-06 19:06:37 +00:00
Address review: include surgery constants in the ld stamp, require size sections, warn on missing extraScript
This commit is contained in:
@@ -398,6 +398,15 @@ def test_generate_ld_scripts(tmp_path: Path) -> None:
|
||||
_run_generate_ld_scripts(paths)
|
||||
mock_run.assert_not_called()
|
||||
|
||||
# An edit to the surgery constants invalidates the stamp (a stale linker
|
||||
# script would otherwise persist until an esphome clean)
|
||||
with (
|
||||
patch.object(arduino8266.build_surgery, "TESTING_FLASH_SIZE", "0x3000000"),
|
||||
patch.object(arduino8266.subprocess, "run", return_value=result) as mock_run,
|
||||
):
|
||||
_run_generate_ld_scripts(paths)
|
||||
mock_run.assert_called_once()
|
||||
|
||||
|
||||
def test_generate_ld_scripts_failure(tmp_path: Path) -> None:
|
||||
|
||||
|
||||
@@ -253,3 +253,22 @@ def test_print_size_summary_unparsable_section(
|
||||
toolchain._print_size_summary(tmp_path, tmp_path / "toolchain")
|
||||
assert "RAM:" in capsys.readouterr().out
|
||||
assert "Unparsable size output" in caplog.text
|
||||
|
||||
|
||||
def test_print_size_summary_missing_section_skips_summary(
|
||||
tmp_path: Path,
|
||||
capsys: pytest.CaptureFixture[str],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""A totals section absent from the output must not default to zero."""
|
||||
without_bss = "\n".join(
|
||||
line for line in _SIZE_OUTPUT.splitlines() if ".bss" not in line
|
||||
)
|
||||
with patch.object(
|
||||
toolchain.subprocess,
|
||||
"run",
|
||||
return_value=MagicMock(returncode=0, stdout=without_bss),
|
||||
):
|
||||
toolchain._print_size_summary(tmp_path, tmp_path / "toolchain")
|
||||
assert capsys.readouterr().out == ""
|
||||
assert "missing section(s) .bss" in caplog.text
|
||||
|
||||
@@ -1270,14 +1270,12 @@ def test_apply_extra_script_pio_platform(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_apply_extra_script_missing_script_logged(tmp_path, caplog) -> None:
|
||||
"""A declared but absent extraScript is skipped with a diagnostic."""
|
||||
import logging
|
||||
"""A declared but absent extraScript is skipped with a visible warning:
|
||||
its captured link flags are lost."""
|
||||
from esphome.espidf.extra_script import apply_extra_script
|
||||
|
||||
c = IDFComponent("owner/name", "1.0", source=URLSource("http://dummy"))
|
||||
c.path = tmp_path
|
||||
c.data = {"build": {"extraScript": "nope.py"}}
|
||||
with caplog.at_level(logging.DEBUG, logger="esphome.espidf.extra_script"):
|
||||
from esphome.espidf.extra_script import apply_extra_script
|
||||
|
||||
apply_extra_script(c, "esp8266")
|
||||
apply_extra_script(c, "esp8266")
|
||||
assert "not found" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user