mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 00:10:22 +00:00
Warn on unresolvable force-includes and pch_defines-less sloppiness, vary the unreadable marker
This commit is contained in:
@@ -117,6 +117,27 @@ def test_parse_entry_keeps_search_chain_force_include(tmp_path: Path) -> None:
|
||||
assert cxx_flags[cxx_flags.index("-include") + 1] == "Arduino.h"
|
||||
|
||||
|
||||
def test_parse_entry_warns_on_vanished_force_include(
|
||||
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""A build-dir force-include deleted by clean_build must leave a trail;
|
||||
a name resolvable via the -I chain must not warn."""
|
||||
inc = tmp_path / "inc"
|
||||
inc.mkdir()
|
||||
(inc / "Arduino.h").write_text("")
|
||||
entry = _entry(
|
||||
str(tmp_path),
|
||||
f"{tmp_path}/src/esphome/x.cpp",
|
||||
f"g++ -I{inc} -include Arduino.h -include esphome_pch.h -c x.cpp",
|
||||
)
|
||||
|
||||
_, _, _, cxx_flags = idedata.parse_entry(entry)
|
||||
|
||||
assert "Arduino.h" in cxx_flags
|
||||
assert "esphome_pch.h" in caplog.text
|
||||
assert "Arduino.h" not in caplog.text
|
||||
|
||||
|
||||
def test_parse_entry_drops_trailing_force_include(
|
||||
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
|
||||
@@ -45,11 +45,22 @@ def test_ccache_pch_env_disabled() -> None:
|
||||
assert pch.ccache_pch_env() == {}
|
||||
|
||||
|
||||
def test_ccache_pch_env_respects_user_values() -> None:
|
||||
def test_ccache_pch_env_respects_user_values(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""A user CCACHE_SLOPPINESS wins, but one without pch_defines silently
|
||||
stops ccache from caching pch consumers, so it must warn."""
|
||||
with patch.dict(os.environ, {"CCACHE_SLOPPINESS": "locale"}, clear=True):
|
||||
env = pch.ccache_pch_env()
|
||||
assert "CCACHE_SLOPPINESS" not in env
|
||||
assert env["CCACHE_PCH_EXTSUM"] == "true"
|
||||
assert "lacks pch_defines" in caplog.text
|
||||
caplog.clear()
|
||||
with patch.dict(
|
||||
os.environ, {"CCACHE_SLOPPINESS": "pch_defines,locale"}, clear=True
|
||||
):
|
||||
pch.ccache_pch_env()
|
||||
assert "lacks pch_defines" not in caplog.text
|
||||
|
||||
|
||||
def test_pch_header_text_preserves_order() -> None:
|
||||
@@ -118,7 +129,9 @@ def test_include_closure_marks_unreadable(
|
||||
closure = pch._include_closure(tmp_path, ["a.h"])
|
||||
finally:
|
||||
locked.chmod(0o644)
|
||||
assert closure["locked.h"] == b"<unreadable>"
|
||||
# stat still works, so the marker varies with mtime/size and a later
|
||||
# edit to the unreadable file still shifts the digest
|
||||
assert closure["locked.h"].startswith(b"<unreadable:")
|
||||
assert "Could not read locked.h" in caplog.text
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user