From 09970b7531519f7244e4daaf6c5718f2b8e40dc7 Mon Sep 17 00:00:00 2001 From: milk4sale <53350507+milk4sale@users.noreply.github.com> Date: Tue, 24 Nov 2026 17:41:49 -0600 Subject: [PATCH] tests: the mod-pack alias test compares resolved names, as same_report_path does (TEST-MOD-PACK-ALIAS-MACOS) tests/test_mod_pack_output_alias.py, added by #1057, fails on macOS and on Windows: test_alias_preflight_precedes_output_truncation ends in "AssertionError: ModsError not raised" for both of its cases. It passes on Linux. The macos-python job stops at the first failing file, so on macOS every test file after this one went unrun. The test replaces os.path.samefile with a function that compares the two paths as tempfile spelled them. report_paths.same_report_path hands samefile the names os.path.realpath gave it, and those are spelled differently where the temporary folder is reached through a link or a short name: /var/folders/... is /private/var/folders/... on macOS, and C:\Users\RUNNER~1\... is C:\Users\runneradmin\... on a Windows runner. The stand-in then never recognises the pair, and pack_mod writes the package. The stand-in now compares resolved names. tools/leonida_mods.py and tools/report_paths.py are right and unchanged. Measured with Python 3.12 on GitHub's runners (a scratch branch on a fork): the file as on main fails on macos-26 and windows-latest with those two failures and passes on ubuntu-24.04; with this change it passes on all three. Control on Linux: with TMPDIR pointing through a symbolic link, main's file fails the same way and this one passes. Co-Authored-By: Claude Fable 5.2 --- tests/test_mod_pack_output_alias.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_mod_pack_output_alias.py b/tests/test_mod_pack_output_alias.py index b11ccca5ef..e2789adc26 100644 --- a/tests/test_mod_pack_output_alias.py +++ b/tests/test_mod_pack_output_alias.py @@ -34,9 +34,13 @@ def test_alias_preflight_precedes_output_truncation(self): before = source.read_bytes() output = root / "packed.zip" output.write_bytes(before) - aliases = {os.path.normcase(str(source)), os.path.normcase(str(output))} + # same_report_path hands samefile the names realpath gave it, which are not the ones tempfile + # spelled where the temporary folder is reached through a link (macOS: /var is /private/var). + def resolved(path): + return os.path.normcase(os.path.realpath(path)) + aliases = {resolved(source), resolved(output)} def samefile(a, b): - return {os.path.normcase(str(a)), os.path.normcase(str(b))} == aliases + return {resolved(a), resolved(b)} == aliases with mock.patch("report_paths.os.path.samefile", side_effect=samefile): with self.assertRaisesRegex(mods.ModsError, "aliases a file"): mods.pack_mod(str(root / "mods"), "sample", str(output), True)