Files
Claude 70429f3b22 Fix review findings without gameplay change (1.3.205)
Package A of the 1.3.204 code review:
- Load: migration and validator run inside the guard, so a malformed save
  is refused instead of ending the game; the load candidate gets its own
  raid RNG, so a failed load leaves the live stream unchanged.
- Ray tracing: the bottom-loss cache now caches (bitwise identical tables,
  35-45 % faster rebuilds).
- Chart rain/storm hatch drawn once into a bounded cache and visible in
  the day scheme.
- Ticker, top bars, hint key maps and tooltips use the memoized text
  helpers.
- Audio: mono synthesis cached without the pan, so a new direction only
  re-pans.
- Browser cue de-duplication keyed by world session and role, not epoch.
- Sonar waterfall tooltip and time label follow the Shift+H window.
- Update download ends as failed on any error; debug/crash logs fall back
  where os.open has no dir_fd (Windows).
- Docs: resume.md save contract, plan-1.3.md marked historical, Intel Mac
  leftovers, changelog, README, station shortcuts, manual PDFs/figures.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LAa6fnf7M4fKm56aJXHvKS
2026-10-04 20:06:10 +00:00

26 lines
1.2 KiB
Python

"""Bounded diagnostic logs (crash, audio, perf) without directory handles."""
import os
from src.core import debuglog
def test_logs_are_written_where_open_takes_no_directory_handle(monkeypatch, tmp_path):
# Windows has no dir_fd support: the crash log used to be silently lost.
monkeypatch.setattr(os, "supports_dir_fd", set())
debuglog.append_bounded_log(tmp_path, "crash.log", "first\n", 1000)
debuglog.append_bounded_log(tmp_path, "crash.log", "second\n", 1000)
assert (tmp_path / "crash.log").read_text(encoding="utf-8") == "first\nsecond\n"
def test_the_fallback_stays_bounded_and_refuses_a_symlinked_file(monkeypatch, tmp_path):
monkeypatch.setattr(os, "supports_dir_fd", set())
debuglog.append_bounded_log(tmp_path, "perf.log", "x" * 20, 10)
debuglog.append_bounded_log(tmp_path, "perf.log", "new\n", 10)
assert (tmp_path / "perf.log").read_text(encoding="utf-8") == "new\n"
target = tmp_path / "elsewhere.txt"
target.write_text("keep", encoding="utf-8")
(tmp_path / "link.log").symlink_to(target)
debuglog.append_bounded_log(tmp_path, "link.log", "no\n", 1000)
assert target.read_text(encoding="utf-8") == "keep"