tests: psocache_extract pins the temporary directory it checks against #10

Merged
leonida/mandy
wavehs merged 1 commit from psocache-tempdir-test into main 2026-11-24 01:40:33 +00:00

Pull request successfully merged and closed

wavehs commented 2026-11-24 01:31:26 +00:00

Claimed in the coordination issue as: none — the original project's coordination issue was lost with its repository, and this repository has no such issue yet. No open pull request touches tests/test_psocache_extract.py.

Depends on: none.

What and why

test_output_outside_the_temp_directory_is_refused expects psocache_extract.py to refuse an output path in the repository root, but the tool compares that path with the system temporary directory. A checkout that lives under /tmp or %TEMP% — the usual sandbox worktree — makes the repository itself "inside" it, the tool writes the cache there and the test fails with 0 != 2 (and leaves the file behind).

The tool is right; the test's environment is not pinned. It now runs the tool with TMPDIR set to a fresh directory, so the refusal holds wherever the tree lives, and removes the output path in a cleanup either way.

Tested

main@30daa6958, macOS 15 arm64 (Apple M3 Pro), CPython 3.15.2, CPU only, no game files, checkout under $TMPDIR:

tree tests/test_psocache_extract.py
main@30daa6958 FAILED (failures=1): 0 != 2 in test_output_outside_the_temp_directory_is_refused
this commit Ran 7 tests ... OK

compileall clean, check_no_game_data.py clean. On a checkout outside the temporary directory the old test passes and this one still does (TMPDIR is only changed for this subprocess).

AI-assisted: yes.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator change.)
Claimed in the coordination issue as: none — the original project's coordination issue was lost with its repository, and this repository has no such issue yet. No open pull request touches `tests/test_psocache_extract.py`. Depends on: none. ### What and why `test_output_outside_the_temp_directory_is_refused` expects `psocache_extract.py` to refuse an output path in the repository root, but the tool compares that path with the system temporary directory. A checkout that lives under `/tmp` or `%TEMP%` — the usual sandbox worktree — makes the repository itself "inside" it, the tool writes the cache there and the test fails with `0 != 2` (and leaves the file behind). The tool is right; the test's environment is not pinned. It now runs the tool with `TMPDIR` set to a fresh directory, so the refusal holds wherever the tree lives, and removes the output path in a cleanup either way. ### Tested `main@30daa6958`, macOS 15 arm64 (Apple M3 Pro), CPython 3.15.2, CPU only, no game files, checkout under `$TMPDIR`: | tree | `tests/test_psocache_extract.py` | |---|---| | `main@30daa6958` | `FAILED (failures=1)`: `0 != 2` in `test_output_outside_the_temp_directory_is_refused` | | this commit | `Ran 7 tests ... OK` | `compileall` clean, `check_no_game_data.py` clean. On a checkout outside the temporary directory the old test passes and this one still does (TMPDIR is only changed for this subprocess). AI-assisted: yes. ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not applicable: no translator change.)
Sign in to join this conversation.
No description provided.