From 4ab5fdc5def7d96de40f3bc3bda9affd005304ba Mon Sep 17 00:00:00 2001 From: MoonEyes <14891700+MoonEyes@users.noreply.github.com> Date: Sun, 29 Nov 2026 20:17:28 +0100 Subject: [PATCH] tests: two Windows reds on main's check job (CI-MAIN-WINDOWS-TESTS) test_gen_gdk_runtime_classes imported the POSIX-only resource module at the top, so the whole file failed to import on Windows. Import it guarded and skip the two failed-write tests that need RLIMIT_FSIZE. test_make_game_plain_logs compared the child's getcwd() with the temp folder as strings; on the Windows runner the temp folder is an 8.3 short name (RUNNER~1) and getcwd() returns the long one. Compare with os.path.samefile. Co-Authored-By: Claude Opus 5.5 --- tests/test_gen_gdk_runtime_classes.py | 10 +++++++++- tests/test_make_game_plain_logs.py | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_gen_gdk_runtime_classes.py b/tests/test_gen_gdk_runtime_classes.py index a54d30df7..dc6681a33 100644 --- a/tests/test_gen_gdk_runtime_classes.py +++ b/tests/test_gen_gdk_runtime_classes.py @@ -2,7 +2,10 @@ import json import os from pathlib import Path -import resource +try: + import resource # POSIX only: the failed-write tests cap the child's file size with it +except ImportError: + resource = None import signal import subprocess import sys @@ -32,7 +35,11 @@ def fail_after_bytes(limit: int): return set_file_limit +NEEDS_RLIMIT = unittest.skipIf(resource is None, "needs POSIX resource limits (RLIMIT_FSIZE)") + + class GenGdkRuntimeClassesTests(unittest.TestCase): + @NEEDS_RLIMIT def test_failed_write_preserves_existing_file(self) -> None: with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) @@ -52,6 +59,7 @@ class GenGdkRuntimeClassesTests(unittest.TestCase): self.assertNotEqual(failed.returncode, 0, failed.stdout.decode(errors="replace")) self.assertEqual(output.read_bytes(), original) + @NEEDS_RLIMIT def test_failed_write_leaves_no_temporary_file(self) -> None: with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) diff --git a/tests/test_make_game_plain_logs.py b/tests/test_make_game_plain_logs.py index e3dca8d20..fabd65e80 100644 --- a/tests/test_make_game_plain_logs.py +++ b/tests/test_make_game_plain_logs.py @@ -151,7 +151,9 @@ class PlainStageLogsTest(unittest.TestCase): make_game.run(child("import os; print(os.getcwd()); print(os.environ['LEONIDA_PLAIN_LOG_TEST'])"), cwd=self.dir.name, env=env, text=True) lines = self.read("pipelines") - self.assertEqual(os.path.normcase(lines[1]), os.path.normcase(os.path.realpath(self.dir.name))) + # samefile, not a string compare: on Windows the temp folder can be an 8.3 short name (RUNNER~1) + # while the child's getcwd() returns the long one. + self.assertTrue(os.path.samefile(lines[1], self.dir.name), (lines[1], self.dir.name)) self.assertEqual(lines[2], "from the caller") def test_inactive_after_the_build_and_appends_like_the_board(self):