test_mod_pack_output_alias: key the fake samefile on realpath, as report_paths does; passes on macOS (TEST-MOD-PACK-ALIAS-REALPATH) #2175

Closed
github-bot wants to merge 2 commits from github-bot/gh-2175 into main AGit
Owner

@⁠Tauwni on GitHub · 2026-11-26 02:03 UTC · original
Tauwni:fix/mod-pack-alias-test-realpath → main · +6 −2 · 1 files · 2 commits · closed without merging

Claimed in the coordination issue as: TEST-MOD-PACK-ALIAS-REALPATH (#1608)

What and why

tests/test_mod_pack_output_alias.py fails on macOS on main:

FAIL: test_alias_preflight_precedes_output_truncation (relative='mod.json')
AssertionError: ModsError not raised
FAIL: ... (relative='nested/notes.txt')
AssertionError: ModsError not raised

The test patches report_paths.os.path.samefile with a fake that answers true for the two paths it built. But report_paths.same_report_path passes samefile the os.path.realpath of each path. On macOS, tempfile's folder /var/folders/... resolves to /private/var/folders/..., so the fake never matches and the alias check never fires. On Linux and Windows the temporary folder isn't a symlink, so the test passes there.

The fix is only in the test: the fake keys on normcase(realpath(path)), like report_paths does. tools/ is unchanged.

Tested

Apple M3, macOS 26.5.1, Python 3.15, on main ad41fd517:

  • Before: 2 failures. With TMPDIR set to a folder that isn't a symlink, the old test passes, which confirms the cause.
  • After: OK, with both the default and a real TMPDIR.
  • With the alias guard in pack_mod disabled, the fixed test fails (4 failures), so it still catches the bug it was written for.
  • tests/test_report_paths.py OK.

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.

🤖 Generated with Claude Code

**@⁠Tauwni** on GitHub · 2026-11-26 02:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2175) `Tauwni:fix/mod-pack-alias-test-realpath` → `main` · +6 −2 · 1 files · 2 commits · closed without merging Claimed in the coordination issue as: TEST-MOD-PACK-ALIAS-REALPATH (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why `tests/test_mod_pack_output_alias.py` fails on macOS on `main`: ``` FAIL: test_alias_preflight_precedes_output_truncation (relative='mod.json') AssertionError: ModsError not raised FAIL: ... (relative='nested/notes.txt') AssertionError: ModsError not raised ``` The test patches `report_paths.os.path.samefile` with a fake that answers true for the two paths it built. But `report_paths.same_report_path` passes `samefile` the `os.path.realpath` of each path. On macOS, `tempfile`'s folder `/var/folders/...` resolves to `/private/var/folders/...`, so the fake never matches and the alias check never fires. On Linux and Windows the temporary folder isn't a symlink, so the test passes there. The fix is only in the test: the fake keys on `normcase(realpath(path))`, like `report_paths` does. `tools/` is unchanged. ### Tested Apple M3, macOS 26.5.1, Python 3.15, on `main` `ad41fd517`: - Before: 2 failures. With `TMPDIR` set to a folder that isn't a symlink, the old test passes, which confirms the cause. - After: OK, with both the default and a real `TMPDIR`. - With the alias guard in `pack_mod` disabled, the fixed test fails (4 failures), so it still catches the bug it was written for. - `tests/test_report_paths.py` OK. AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On macOS the temporary folder /var/... resolves to /private/var/..., so the fake never matched the resolved paths
report_paths passes it and test_alias_preflight_precedes_output_truncation failed (ModsError not raised).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:21:16 +00:00
Author
Owner

@⁠EdenBendheim on GitHub · 2026-11-26 05:17 UTC · original

Note

🤖 gpt-6.2-sol responding on behalf of EdenBendheim

Independent verification of head 904dfe2500b739fb3e2f418d3246e5f7ca70c6bf applied to current main a73a57e13 (macOS 27.3, Apple M1 Max, Python 3.12.14, synthetic fixtures only).

  • Main: both alias-preflight subtests fail with the default temporary directory; resolving TMPDIR through realpath makes them pass.
  • PR: test_mod_pack_output_alias.py passes 3/3 under both configurations.
  • test_report_paths.py: all 24 tests accounted for (23 passed, one expected platform skip).
  • Clean simulated merge, no-game-data and diff checks.

This resolves the other pre-existing failure observed in the full standalone test run for #2193. Test-only correction, no defects found.

**@⁠EdenBendheim** on GitHub · 2026-11-26 05:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2175#issuecomment-7183349644) > [!NOTE] > 🤖 **gpt-6.2-sol responding on behalf of EdenBendheim** Independent verification of head `904dfe2500b739fb3e2f418d3246e5f7ca70c6bf` applied to current main `a73a57e13` (macOS 27.3, Apple M1 Max, Python 3.12.14, synthetic fixtures only). - Main: both alias-preflight subtests fail with the default temporary directory; resolving TMPDIR through realpath makes them pass. - PR: `test_mod_pack_output_alias.py` passes 3/3 under both configurations. - `test_report_paths.py`: all 24 tests accounted for (23 passed, one expected platform skip). - Clean simulated merge, no-game-data and diff checks. This resolves the other pre-existing failure observed in the full standalone test run for #2193. Test-only correction, no defects found.
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 10:12 UTC · original

Checked on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13). Merges cleanly. python -I tests/test_mod_pack_output_alias.py: 3 tests OK with this PR, and also OK on main: the failure it fixes is macOS-only by its title, and Linux does not reproduce it, so this is only a Linux no-regression check, not a confirmation of the macOS fix.

AI-assisted: yes (Claude Code)

**@⁠real-rusher** on GitHub · 2026-11-26 10:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2175#issuecomment-7189057469) Checked on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13). Merges cleanly. python -I tests/test_mod_pack_output_alias.py: 3 tests OK with this PR, and also OK on main: the failure it fixes is macOS-only by its title, and Linux does not reproduce it, so this is only a Linux no-regression check, not a confirmation of the macOS fix. AI-assisted: yes (Claude Code)
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 10:20 UTC · original

Follow-up to my earlier comment: the failure does reproduce on Linux once the temp folder is reached through a link. With TMPDIR pointing at a symbolic link (/tmp/linktmp -> /tmp/realtmp), python -I tests/test_mod_pack_output_alias.py fails on main (2 failures) and passes with this PR.

Possible duplicate: the older open #1412 (TEST-MOD-PACK-ALIAS-MACOS) makes the same fix to the same file and also passes this control; the two conflict, so only one of them should land.

AI-assisted: yes (Claude Code)

**@⁠real-rusher** on GitHub · 2026-11-26 10:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2175#issuecomment-7189233273) Follow-up to my earlier comment: the failure does reproduce on Linux once the temp folder is reached through a link. With TMPDIR pointing at a symbolic link (/tmp/linktmp -> /tmp/realtmp), python -I tests/test_mod_pack_output_alias.py fails on main (2 failures) and passes with this PR. Possible duplicate: the older open #1412 (TEST-MOD-PACK-ALIAS-MACOS) makes the same fix to the same file and also passes this control; the two conflict, so only one of them should land. AI-assisted: yes (Claude Code)
Author
Owner

@⁠TheGeogeo on GitHub · 2026-11-26 17:07 UTC · original · edited 2026-11-26 17:11 UTC

Independent check on Windows of head 011fbd3a9e, merged into main 935a2cd5b (clean merge). Windows 11 Pro 10.0.26300, Python 3.12.4, CPU only, synthetic fixtures, no game data.

The failure is not macOS-only. It also happens on Windows when TEMP is an 8.3 short name, which is the default on this machine (C:\Users\<USERNA~1>\AppData\Local\Temp, the 8.3 form of C:\Users\<username>). realpath expands it to the long spelling, so the fake samefile never sees the names it was keyed on, the same way /var becomes /private/var on macOS.

  • main 935a2cd5b: python -I tests/test_mod_pack_output_alias.py fails, 2 failures in 3 tests (ModsError not raised, both subtests of test_alias_preflight_precedes_output_truncation). The file also fails in a local run of the Windows check job's standalone-test step. With TEMP and TMP set to the long spelling, the same file passes, 3 of 3.
  • This PR merged with main: 3 of 3 OK with the short TEMP (4 runs) and with the long one. The head alone: OK.
  • Negative control: with the raise ModsError(...) in pack_mod (tools/leonida_mods.py:492) replaced by pass, the test fails (4 failures). It still catches the alias.
  • tests/test_report_paths.py: OK. scripts/check_no_game_data.py and git diff --check on the changed file: clean.

So the description's "On Linux and Windows the temporary folder isn't a symlink, so the test passes there" does not hold for Windows with a short-name TEMP. The change fixes that case too.

Duplicate, as real-rusher noted: #1412 (head 09970b7531) makes the same change. Merged with the same main, it gives the same results here: 3 of 3 with both TEMP spellings, and 4 failures with the guard removed. Only one of the two should land.

AI-assisted: yes (Claude Code).

Status: OK to merge. The gain is real: it turns a test that fails on main on Windows (short-name TEMP) and on macOS green, and keeps it catching the alias. Duplicate of #1412 (same change, opened first): merge one of the two and close the other.

**@⁠TheGeogeo** on GitHub · 2026-11-26 17:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2175#issuecomment-7198538171) · edited 2026-11-26 17:11 UTC Independent check on Windows of head `011fbd3a9e`, merged into `main` `935a2cd5b` (clean merge). Windows 11 Pro 10.0.26300, Python 3.12.4, CPU only, synthetic fixtures, no game data. The failure is not macOS-only. It also happens on Windows when `TEMP` is an 8.3 short name, which is the default on this machine (`C:\Users\<USERNA~1>\AppData\Local\Temp`, the 8.3 form of `C:\Users\<username>`). `realpath` expands it to the long spelling, so the fake `samefile` never sees the names it was keyed on, the same way `/var` becomes `/private/var` on macOS. - `main` `935a2cd5b`: `python -I tests/test_mod_pack_output_alias.py` fails, 2 failures in 3 tests (`ModsError not raised`, both subtests of `test_alias_preflight_precedes_output_truncation`). The file also fails in a local run of the Windows `check` job's standalone-test step. With `TEMP` and `TMP` set to the long spelling, the same file passes, 3 of 3. - This PR merged with `main`: 3 of 3 OK with the short `TEMP` (4 runs) and with the long one. The head alone: OK. - Negative control: with the `raise ModsError(...)` in `pack_mod` (`tools/leonida_mods.py:492`) replaced by `pass`, the test fails (4 failures). It still catches the alias. - `tests/test_report_paths.py`: OK. `scripts/check_no_game_data.py` and `git diff --check` on the changed file: clean. So the description's "On Linux and Windows the temporary folder isn't a symlink, so the test passes there" does not hold for Windows with a short-name `TEMP`. The change fixes that case too. Duplicate, as real-rusher noted: #1412 (head `09970b7531`) makes the same change. Merged with the same `main`, it gives the same results here: 3 of 3 with both `TEMP` spellings, and 4 failures with the guard removed. Only one of the two should land. AI-assisted: yes (Claude Code). **Status:** OK to merge. The gain is real: it turns a test that fails on `main` on Windows (short-name `TEMP`) and on macOS green, and keeps it catching the alias. Duplicate of #1412 (same change, opened first): merge one of the two and close the other.
Author
Owner

@⁠wavehs on GitHub · 2026-11-26 18:09 UTC · original

Verified independently on main bd6ba97ab (macOS 27.2.1 arm64, Python 3.15.2, no numpy), with the PR diff applied:

Before (python3 -I tests/test_mod_pack_output_alias.py, unmodified main):

FAIL: test_alias_preflight_precedes_output_truncation (relative='mod.json')
AssertionError: ModsError not raised
FAIL: test_alias_preflight_precedes_output_truncation (relative='nested/notes.txt')
AssertionError: ModsError not raised
Ran 3 tests ... FAILED (failures=2)

After: Ran 3 tests ... OK.

Negative control: with the same_report_path preflight removed from pack_mod, the fixed test fails again (FAILED (failures=4)), so it still catches the alias it was written for, not just the spelling.

I also confirmed the cause from the other side: pointing TMPDIR at a folder that is not a symlink makes the old test pass. The change is test-only, and os.path.realpath is exactly what report_paths.same_report_path now feeds samefile. Looks right to me.

AI-assisted (verification run only).

**@⁠wavehs** on GitHub · 2026-11-26 18:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2175#issuecomment-7200128130) Verified independently on `main` `bd6ba97ab` (macOS 27.2.1 arm64, Python 3.15.2, no numpy), with the PR diff applied: **Before** (`python3 -I tests/test_mod_pack_output_alias.py`, unmodified main): ``` FAIL: test_alias_preflight_precedes_output_truncation (relative='mod.json') AssertionError: ModsError not raised FAIL: test_alias_preflight_precedes_output_truncation (relative='nested/notes.txt') AssertionError: ModsError not raised Ran 3 tests ... FAILED (failures=2) ``` **After**: `Ran 3 tests ... OK`. **Negative control**: with the `same_report_path` preflight removed from `pack_mod`, the fixed test fails again (`FAILED (failures=4)`), so it still catches the alias it was written for, not just the spelling. I also confirmed the cause from the other side: pointing `TMPDIR` at a folder that is not a symlink makes the old test pass. The change is test-only, and `os.path.realpath` is exactly what `report_paths.same_report_path` now feeds `samefile`. Looks right to me. AI-assisted (verification run only).
Author
Owner

@⁠wavehs on GitHub · 2026-11-26 18:16 UTC · original

Heads-up for the coordinator: this is a duplicate of #1412 (milk4sale, opened 2026-11-24 23:42, before this one), and that PR is the stronger of the two:

  • Same fix, same file, same three lines of reasoning (normcase(realpath(...)) in the fake samefile).
  • #1412 also names the Windows half of the bug: C:\Users\RUNNER~1\... vs C:\Users\runneradmin\..., so the test fails on the check job for the same reason, not only on macOS.
  • It measured the file on macos-26, windows-latest and ubuntu-24.04 before/after in its fork CI.

Both apply cleanly to main bd6ba97ab; I verified this one's test result (3 tests OK) in my comment above, so there is nothing wrong with it — just no reason to merge both. My vote is to land #1412 and close this one; if this one lands first, #1412 needs closing instead.

AI-assisted (review only).

**@⁠wavehs** on GitHub · 2026-11-26 18:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2175#issuecomment-7200270851) Heads-up for the coordinator: this is a duplicate of #1412 (milk4sale, opened 2026-11-24 23:42, before this one), and that PR is the stronger of the two: - Same fix, same file, same three lines of reasoning (`normcase(realpath(...))` in the fake `samefile`). - #1412 also names the **Windows** half of the bug: `C:\Users\RUNNER~1\...` vs `C:\Users\runneradmin\...`, so the test fails on the `check` job for the same reason, not only on macOS. - It measured the file on `macos-26`, `windows-latest` and `ubuntu-24.04` before/after in its fork CI. Both apply cleanly to `main` `bd6ba97ab`; I verified this one's test result (3 tests OK) in my comment above, so there is nothing wrong with it — just no reason to merge both. My vote is to land #1412 and close this one; if this one lands first, #1412 needs closing instead. AI-assisted (review only).
github-bot closed this pull request 2026-11-27 00:36:36 +00:00
Author
Owner

@⁠Tauwni on GitHub · 2026-11-26 23:51 UTC · original

Closing as a duplicate of #1412 (milk4sale), which was opened first with the same realpath fix and also covers the Windows side. Thanks @⁠wavehs for spotting it. I confirmed #1412 on the M3 there.

AI-assisted (Claude Code).

**@⁠Tauwni** on GitHub · 2026-11-26 23:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2175#issuecomment-7205928570) Closing as a duplicate of #1412 (milk4sale), which was opened first with the same `realpath` fix and also covers the Windows side. Thanks @⁠wavehs for spotting it. I confirmed #1412 on the M3 there. AI-assisted (Claude Code).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.