mirror of
https://github.com/esphome/esphome.git
synced 2026-09-29 16:00:23 +00:00
Run the gch compile from its resolution dir, self-clean when disabled, log the opt-out hint, pin the knob in tests
This commit is contained in:
@@ -492,6 +492,12 @@ def test_get_component_cmakelists_no_compile_features() -> None:
|
||||
assert "target_compile_features" not in content
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _pch_default_on(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Pin the knob so a developer's ESPHOME_PCH_ENABLE=0 cannot fail these."""
|
||||
monkeypatch.setenv("ESPHOME_PCH_ENABLE", "1")
|
||||
|
||||
|
||||
def _make_pch_device(tmp_path: Path, name: str) -> Path:
|
||||
"""A device dir with the pch source headers and a stub compile_commands."""
|
||||
from esphome.build_helpers.pch import PCH_DEFAULT_HEADERS
|
||||
@@ -634,7 +640,8 @@ def test_pch_compile_command_variants(tmp_path: Path) -> None:
|
||||
)
|
||||
)
|
||||
# Launcher stripped; -include/-o/-c and depfile flags removed
|
||||
assert pch_compile_command(build, header, gch) == [
|
||||
cmd, cmd_dir = pch_compile_command(build, header, gch)
|
||||
assert cmd == [
|
||||
"g++",
|
||||
"-DX=1",
|
||||
"-x",
|
||||
@@ -644,6 +651,8 @@ def test_pch_compile_command_variants(tmp_path: Path) -> None:
|
||||
"-o",
|
||||
str(gch),
|
||||
]
|
||||
# The compile must run where the flags were resolved
|
||||
assert cmd_dir == build
|
||||
|
||||
|
||||
def test_pch_compile_command_rejects_unusable_entries(tmp_path: Path) -> None:
|
||||
@@ -947,6 +956,6 @@ def test_prepare_pch_keeps_user_force_includes(tmp_path: Path) -> None:
|
||||
]
|
||||
)
|
||||
)
|
||||
cmd = pch_compile_command(build, build / "esphome_pch.h", build / "x.gch")
|
||||
cmd, _ = pch_compile_command(build, build / "esphome_pch.h", build / "x.gch")
|
||||
assert "user.h" in cmd
|
||||
assert "esphome_pch.h" not in " ".join(cmd[:-3])
|
||||
|
||||
@@ -1582,6 +1582,9 @@ def test_ccache_env_default_enabled_when_available(tmp_path: Path) -> None:
|
||||
assert env["CCACHE_NOHASHDIR"] == "true"
|
||||
assert env["CCACHE_DEPEND"] == "1"
|
||||
assert env["CCACHE_BASEDIR"] == str((tmp_path / "build").resolve())
|
||||
# The pch cannot cache under ccache without these
|
||||
assert env["CCACHE_SLOPPINESS"] == "pch_defines,time_macros"
|
||||
assert env["CCACHE_PCH_EXTSUM"] == "true"
|
||||
|
||||
|
||||
def test_ccache_env_disabled_when_binary_missing(tmp_path: Path) -> None:
|
||||
@@ -1991,12 +1994,3 @@ def test_ccache_env_opt_in_with_usable_binary(
|
||||
env = _ccache_env()
|
||||
assert env["IDF_CCACHE_ENABLE"] == "1"
|
||||
assert not [r for r in caplog.records if r.levelno >= logging.WARNING]
|
||||
|
||||
|
||||
def test_ccache_env_exports_pch_settings(tmp_path: Path) -> None:
|
||||
# The pch cannot cache under ccache without these
|
||||
p1, p2, p3 = _ccache_patches(tmp_path, "/usr/bin/ccache", tmp_path / "build")
|
||||
with patch.dict("os.environ", {}, clear=True), p1, p2, p3:
|
||||
env = _ccache_env()
|
||||
assert env["CCACHE_SLOPPINESS"] == "pch_defines,time_macros"
|
||||
assert env["CCACHE_PCH_EXTSUM"] == "true"
|
||||
|
||||
Reference in New Issue
Block a user