"""A report tool must never truncate the file it was asked to index. Run with ``python -I tests/test_report_source_collision.py``. Set ``LEONIDA_TOOLS_DIR`` to compare against another revision of the tools (used as the negative control: on main these tests fail because the source file is replaced by the report). All inputs are built here by hand; no game file or game data is used. """ import os import struct import subprocess import sys import tempfile import unittest import zlib ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) TOOLS_DIR = os.environ.get("LEONIDA_TOOLS_DIR", os.path.join(ROOT, "tools")) SENTINEL = b"SYNTHETIC-SOURCE-DO-NOT-OVERWRITE\n" * 4 def make_bink(): return SENTINEL def make_rpf(payload, head_size=0x40): head = bytearray(head_size) head[0:4] = b"9FPR" struct.pack_into("