mirror of
https://github.com/esphome/esphome.git
synced 2026-10-05 02:21:30 +00:00
Merge branch 'esp8266-native-pch' into esp32-idf-pch
This commit is contained in:
@@ -416,6 +416,21 @@ def test_write_project_pch_identity_unknown_skips_pch(
|
||||
assert "Could not establish the pch identity" in caplog.text
|
||||
|
||||
|
||||
def test_write_project_pch_skipped_when_user_force_include_precedes(
|
||||
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""A -include in build_flags lands ahead of the pch include, so GCC
|
||||
would never load the .gch; skip it and say so."""
|
||||
paths = _make_framework(tmp_path)
|
||||
_set_flags(
|
||||
"-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH", "-include foo.h"
|
||||
)
|
||||
content = _write_ninja(paths, ccache="/usr/bin/ccache")
|
||||
assert "esphome_pch" not in content
|
||||
assert "srccxxflags" not in content
|
||||
assert "prevents the precompiled header" in caplog.text
|
||||
|
||||
|
||||
def test_write_project_pch_disabled(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
|
||||
@@ -45,6 +45,15 @@ def test_ccache_pch_env_disabled() -> None:
|
||||
assert pch.ccache_pch_env() == {}
|
||||
|
||||
|
||||
def test_ccache_pch_env_token_check_is_membership_not_substring(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""A token merely containing ours must not suppress the union."""
|
||||
with patch.dict(os.environ, {"CCACHE_SLOPPINESS": "pch_defines_extra"}, clear=True):
|
||||
env = pch.ccache_pch_env()
|
||||
assert env["CCACHE_SLOPPINESS"] == "pch_defines_extra,pch_defines,time_macros"
|
||||
|
||||
|
||||
def test_ccache_pch_env_unions_user_sloppiness(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
@@ -181,3 +190,12 @@ def test_pch_checksum_survives_surrogate_extra(tmp_path: Path) -> None:
|
||||
"""Install paths from non-UTF-8 filesystems carry surrogates; hashing
|
||||
them must not raise past the caller's identity-unknown guard."""
|
||||
assert pch.pch_checksum(tmp_path, [], ["/opt/bad\udcff/framework"])
|
||||
|
||||
|
||||
def test_include_closure_walks_angle_includes_under_src(tmp_path: Path) -> None:
|
||||
"""An angle include resolving under src/ must enter the digest; one
|
||||
that does not simply ends the walk."""
|
||||
_write(tmp_path, "a.h", "#include <local.h>\n#include <Arduino.h>\n")
|
||||
(tmp_path / "local.h").write_text("")
|
||||
closure = pch._include_closure(tmp_path, ["a.h"])
|
||||
assert set(closure) == {"a.h", "local.h"}
|
||||
|
||||
@@ -284,6 +284,16 @@ def test_pch_script_package_version_error_skips_pch(tmp_path: Path) -> None:
|
||||
assert scons_env.prepended == []
|
||||
|
||||
|
||||
def test_pch_script_corrupt_sidecar_reads_as_stale(tmp_path: Path) -> None:
|
||||
"""A truncated/corrupt .failed marker must not disable the pch forever."""
|
||||
_run_script(tmp_path, fail=True)
|
||||
proj = tmp_path / "dev"
|
||||
(proj / "esphome_pch.h.gch.failed").write_bytes(b"\xff\xfe corrupt")
|
||||
_run_script(tmp_path)
|
||||
assert (proj / "esphome_pch.h.gch").is_file()
|
||||
assert (proj / "esphome_pch.h.gch.sum").is_file()
|
||||
|
||||
|
||||
def test_pch_script_rebuilds_when_header_missing(tmp_path: Path) -> None:
|
||||
_run_script(tmp_path)
|
||||
proj = tmp_path / "dev"
|
||||
|
||||
Reference in New Issue
Block a user