mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 00:40:21 +00:00
Merge branch 'esp8266-native-ninja-emission' into esp8266-arduino-toolchain
This commit is contained in:
@@ -224,7 +224,7 @@ def test_apply_extra_script_swallows_script_errors(tmp_path, caplog) -> None:
|
||||
c.data = {"build": {"extraScript": "extra.py"}}
|
||||
apply_extra_script(c, board_mcu=lambda: "esp8266", pio_platform="espressif8266")
|
||||
assert "flags" not in c.data["build"]
|
||||
assert "skipping" in caplog.text
|
||||
assert "keeping the partial capture" in caplog.text
|
||||
|
||||
|
||||
def test_apply_extra_script_pio_platform(tmp_path) -> None:
|
||||
@@ -250,3 +250,16 @@ def test_apply_extra_script_missing_script_logged(tmp_path, caplog) -> None:
|
||||
c.data = {"build": {"extraScript": "nope.py"}}
|
||||
apply_extra_script(c, board_mcu=lambda: "esp8266", pio_platform="espressif8266")
|
||||
assert "not found" in caplog.text
|
||||
|
||||
|
||||
def test_run_extra_script_keeps_partial_capture(tmp_path, caplog) -> None:
|
||||
"""Flags appended before a script fails are kept, not dropped."""
|
||||
from esphome.platformio.extra_script import run_extra_script
|
||||
|
||||
script = tmp_path / "extra.py"
|
||||
script.write_text("env.Append(LIBS=['algobsec'])\nraise RuntimeError('boom')\n")
|
||||
result = run_extra_script(
|
||||
script, library_dir=tmp_path, board_mcu="esp32", pio_platform="espressif32"
|
||||
)
|
||||
assert result.libs == ["algobsec"]
|
||||
assert "keeping the partial capture" in caplog.text
|
||||
|
||||
@@ -564,3 +564,16 @@ def test_lex_build_flags_dangling_flag_does_not_cross_entries(
|
||||
|
||||
assert lex_build_flags(["-Wall -I", "-DFOO=1"], "lib x") == ["-Wall", "-DFOO=1"]
|
||||
assert "Ignoring trailing '-I'" in caplog.text
|
||||
|
||||
|
||||
def test_split_flag_entry_non_string_is_clean( # type: ignore[no-untyped-def]
|
||||
) -> None:
|
||||
"""A dict or number from a third-party manifest fails naming the entry,
|
||||
not with an opaque shlex traceback."""
|
||||
from esphome.core import EsphomeError
|
||||
from esphome.platformio.library import split_flag_entry
|
||||
|
||||
with pytest.raises(EsphomeError, match="Malformed build flag"):
|
||||
split_flag_entry({"esp32": ["-DX"]}, "lib x")
|
||||
with pytest.raises(EsphomeError, match="Malformed build flag 5"):
|
||||
split_flag_entry(5, "lib x")
|
||||
|
||||
@@ -149,3 +149,32 @@ def test_print_summary_flash_line(
|
||||
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
|
||||
|
||||
|
||||
def test_print_summary_missing_ram_region_warns(
|
||||
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""A missing RAM line is diagnosable, not a silently absent CI metric."""
|
||||
size_json = _write_size_json(tmp_path, {"memory_types": {}, "image_size": 100})
|
||||
print_summary(size_json, partitions_csv=None)
|
||||
assert "Skipping RAM summary" in caplog.text
|
||||
|
||||
|
||||
def test_print_summary_bad_partitions_warns(
|
||||
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""An unparseable partition table skips the Flash line with a warning."""
|
||||
size_json = _write_size_json(tmp_path, _esp32_size_data())
|
||||
partitions = tmp_path / "partitions.csv"
|
||||
partitions.write_text("not,a,valid,partition,table\n")
|
||||
print_summary(size_json, partitions_csv=partitions)
|
||||
assert "Skipping Flash summary" in caplog.text
|
||||
|
||||
|
||||
def test_print_summary_corrupt_json_warns(
|
||||
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
size_json = tmp_path / "size.json"
|
||||
size_json.write_text("{not json")
|
||||
print_summary(size_json, partitions_csv=None)
|
||||
assert "Skipping size summary" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user