Merge branch 'pch-strict-ci' into host-pch

This commit is contained in:
J. Nick Koston
2026-08-27 09:40:58 -05:00
3 changed files with 17 additions and 2 deletions
+5 -1
View File
@@ -85,7 +85,11 @@ def _run_copy(src: str, dst: str) -> int:
def _run_touch(path: str) -> int:
Path(path).touch()
try:
Path(path).touch()
except OSError as err:
print(f"touch: {path} failed: {err}", file=sys.stderr)
return 1
return 0
@@ -254,3 +254,11 @@ def test_touch_creates_and_updates_stamp(tmp_path: Path) -> None:
os.utime(stamp, (1, 1))
assert build_tool._run_touch(str(stamp)) == 0
assert stamp.stat().st_mtime > 1
def test_touch_reports_failure(
tmp_path: Path, capsys: pytest.CaptureFixture[str]
) -> None:
missing_dir = tmp_path / "gone" / "stamp"
assert build_tool._run_touch(str(missing_dir)) == 1
assert "touch:" in capsys.readouterr().err
@@ -478,7 +478,10 @@ def test_pch_script_strict_tables_match_helpers(tmp_path: Path) -> None:
proj = tmp_path / "dev"
(proj / "src").mkdir(parents=True)
env = _FakeSConsEnv(proj, proj / "src", "g++", ["-DX=1"])
# Hermetic: the constants are module-level, but the exec still runs
# _setup_pch, which must not touch the host toolchain
cxx = _fake_cxx(tmp_path)
env = _FakeSConsEnv(proj, proj / "src", str(cxx), ["-DX=1"])
namespace = {"Import": lambda *_names: None, "env": env, "projenv": env}
with patch.dict(os.environ, {}, clear=True):
exec(compile(_SCRIPT.read_text(), "pch.py", "exec"), namespace) # noqa: S102