mirror of
https://github.com/esphome/esphome.git
synced 2026-10-02 09:20:22 +00:00
Warn when a compile entry does not lead with a compiler and fail on an empty core archive
This commit is contained in:
@@ -646,3 +646,22 @@ def test_shell_token_escaping() -> None:
|
||||
assert arduino8266._shell_token('-DX=a\\"b c') == '"-DX=a\\\\\\"b c"'
|
||||
# A trailing backslash run doubles before the closing quote
|
||||
assert arduino8266._shell_token("a b\\") == '"a b\\\\"'
|
||||
|
||||
|
||||
def test_write_project_empty_core_raises(tmp_path: Path) -> None:
|
||||
"""A framework tree with no core sources fails at generation, not link."""
|
||||
paths = _make_framework(tmp_path)
|
||||
core = paths["framework_path"] / "cores" / "esp8266"
|
||||
for f in core.iterdir():
|
||||
f.unlink()
|
||||
_set_flags()
|
||||
src = CORE.relative_src_path()
|
||||
(src / "esphome" / "components" / "esp8266").mkdir(parents=True, exist_ok=True)
|
||||
(src / "main.cpp").write_text("")
|
||||
with (
|
||||
patch.object(arduino8266, "generate_ld_scripts"),
|
||||
patch("esphome.arduino8266.component.resolve_libraries", return_value=[]),
|
||||
patch("esphome.arduino8266.framework.ccache_path", return_value=None),
|
||||
pytest.raises(EsphomeError, match="no core sources"),
|
||||
):
|
||||
arduino8266.write_project(paths)
|
||||
|
||||
@@ -279,11 +279,26 @@ def test_parse_entry_strips_launcher_prefix() -> None:
|
||||
assert cxx_path == "/tools/xtensa-lx106-elf-g++"
|
||||
assert defines == ["USE_ESP8266"]
|
||||
# Without a configured launcher nothing is stripped, even a token that
|
||||
# happens to be named ccache
|
||||
# happens to be named ccache -- but the surprise is warned about
|
||||
cxx_path, _, _, _ = idedata._parse_entry(entry)
|
||||
assert cxx_path == "/opt/homebrew/bin/ccache"
|
||||
|
||||
|
||||
def test_parse_entry_warns_when_first_token_is_not_a_compiler(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
entry = _entry(
|
||||
f"{ABS}build",
|
||||
f"{ABS}build/src/esphome/core/application.cpp",
|
||||
"/opt/homebrew/bin/ccache /tools/xtensa-lx106-elf-g++ -c a.cpp -o a.o",
|
||||
)
|
||||
idedata._parse_entry(entry)
|
||||
assert "does not start with a compiler" in caplog.text
|
||||
caplog.clear()
|
||||
idedata._parse_entry(entry, launcher="/opt/homebrew/bin/ccache")
|
||||
assert "does not start with a compiler" not in caplog.text
|
||||
|
||||
|
||||
def _write_compile_commands(tmp_path: Path) -> Path:
|
||||
compile_commands = tmp_path / "compile_commands.json"
|
||||
compile_commands.write_text(
|
||||
|
||||
Reference in New Issue
Block a user