Files
mandy/tests/test_console_paths.py
Jan Trencansky 297ad86854 file_system: T: is a folder of each process's own in the overlay
T:\ mapped to <overlay>\.gta6rt-temp, one folder shared by every run and
kept between runs. The title makes its crash dump and crash log there
with CREATE_NEW, and a name an earlier run (or a second process) had
left failed with ERROR_FILE_EXISTS (80), so no report landed (old
upstream issue 7913, measured by Spacecer2 under Wine 11.22).

T:\ now names <overlay>\.gta6rt-temp\<YYYYMMDD-HHMMSS-mmm>-pid<id>, the
process's start time in UTC and its id, made on the first T: call. The
start time keeps a reused process id (Wine hands each fresh prefix the
same small ids) out of an old run's folder. T:\.. cannot climb into the
shared folder, T:\ itself still cannot be removed or moved, and earlier
runs' folders are kept so their crash files can be read. GAME: and G:
are unchanged.

rt::fs::scratch_dir() returns the folder, and the startup line names it:
"console paths: GAME: -> ..., writes -> ..., T: -> ...". The two CMake
checks of that line (run_tiny_game_console_paths, run_tiny_game_dir)
and the synthetic test of the first now expect the T: part.

file_system_test: a CREATE_NEW of a name earlier runs left in
.gta6rt-temp succeeds and lands in the process's own folder; the folder
is stable for the process; a second process (the test started again)
creating the same name on the same overlay succeeds in a folder of its
own; GAME: reads and writes are unchanged. On main these fail with
ERROR_FILE_EXISTS (80), in this process and in the second one.

Restored from old upstream PR 8161 and ported onto the new main: the
folder is made through main's win32_io_path, so long overlay roots keep
working, and the scratch-folder check of the write-open path is kept.
Main's long-overlay T: check now finds scratch.bin in the process's own
folder below .gta6rt-temp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 06:54:36 -05:00

45 lines
1.9 KiB
Python

"""Exercise the Unicode console paths CMake check with a synthetic loader."""
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest
CHECK = Path(__file__).resolve().parents[1] / "runtime/test/check_console_paths.cmake"
CMAKE = shutil.which("cmake")
@unittest.skipUnless(CMAKE, "CMake is required to exercise the console paths check")
class ConsolePathsTests(unittest.TestCase):
def test_requires_the_guest_to_finish_successfully(self):
cases = (
("successful guest", "tiny_game: OK\ngame exited with code 0\n", 0),
("paths only", "", 1),
("guest failure", "tiny_game: FAILED\ngame exited with code 1\n", 1),
("guest OK without loader exit", "tiny_game: OK\n", 1),
("loader exit without guest OK", "game exited with code 0\n", 1),
)
with tempfile.TemporaryDirectory() as tmp:
loader = Path(tmp) / "loader.py"
for name, verdict, expected in cases:
with self.subTest(name=name):
output = ("console paths: GAME: -> game-Игра, writes -> overlay-保存, "
"T: -> overlay-保存\\.gta6rt-temp\\20261123-181502-123-pid42\n" + verdict)
loader.write_text(
f"import sys\nsys.stdout.buffer.write({output.encode('utf-8')!r})\n",
encoding="utf-8", newline="\n",
)
result = subprocess.run(
[CMAKE, f"-DRUNNER={sys.executable}", f"-DLOADER={loader}",
"-DGUEST=synthetic.exe", "-P", str(CHECK)],
cwd=tmp, capture_output=True, encoding="utf-8", errors="replace",
timeout=10, check=False,
)
self.assertEqual(result.returncode, expected, result.stdout + result.stderr)
if __name__ == "__main__":
unittest.main()