tests: cover partial Windows known-folder results (TEST-WINDOWS-KNOWN-FOLDERS) #835

Merged
leonida/mandy
TheGeogeo merged 2 commits from test/windows-known-folders-partial into main 2026-11-29 14:27:12 +00:00

Pull request successfully merged and closed

TheGeogeo commented 2026-11-24 14:22:07 +00:00

Claimed in the coordination issue as: TEST-WINDOWS-KNOWN-FOLDERS

What and why

known_folders() can return partial results. The live test expected all three paths and failed when the restricted Windows shell returned two. Allow the documented result count, retain the live absolute-path and repeat-call checks, and add a mock shell test that verifies partial results and buffer cleanup.

This test-only change carries forward my earlier ProjectLeonida/Leonida PR #10060, rechecked against this repository's main.

Tested

After a rebase on main 56bdd7e8 (56d42dab, same patch as 528dc900), on Windows 11, Python 3.12.4: tests/test_make_game_preflight.py 110 run, OK (1 skipped), also from a venv whose path has a space; tests/test_make_game_pipeline_preflight.py 23 run, OK (1 skipped); test_tool_stdout_encoding.py, test_docs_cli_flags.py, test_text_write_line_endings.py, test_ctest_registration.py and test_ci_registration.py OK; git diff --check and the no-game-data check clean.

  • Windows, Python 3.12.4. The focused GameDiscoveryTest.test_known_folders_from_the_shell failed on main at d0da7dad with 2 != 3 in the restricted session.
  • python -I -B tests/test_make_game_preflight.py on this branch: 98 passed and 1 skipped in both the restricted and normal Windows sessions. The skipped test requires a case-sensitive filesystem.
  • python -I -B tests/test_make_game_pipeline_preflight.py: 19 passed and 1 skipped. The skipped test requires POSIX execute permissions.
  • git diff --check and python -I -B scripts/check_no_game_data.py tests/test_make_game_preflight.py: passed.

GPUs tested: n/a. CPU-only tests.

AI-assisted: Yes, Codex.

Checklist

  • Based on current main.
  • One topic.
  • No game data, keys, or decryption.
  • Translator contract entry: not applicable.
Claimed in the coordination issue as: [TEST-WINDOWS-KNOWN-FOLDERS](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134202075) ### What and why `known_folders()` can return partial results. The live test expected all three paths and failed when the restricted Windows shell returned two. Allow the documented result count, retain the live absolute-path and repeat-call checks, and add a mock shell test that verifies partial results and buffer cleanup. This test-only change carries forward my earlier `ProjectLeonida/Leonida` PR #10060, rechecked against this repository's `main`. ### Tested After a rebase on `main` `56bdd7e8` (`56d42dab`, same patch as `528dc900`), on Windows 11, Python 3.12.4: `tests/test_make_game_preflight.py` 110 run, OK (1 skipped), also from a venv whose path has a space; `tests/test_make_game_pipeline_preflight.py` 23 run, OK (1 skipped); `test_tool_stdout_encoding.py`, `test_docs_cli_flags.py`, `test_text_write_line_endings.py`, `test_ctest_registration.py` and `test_ci_registration.py` OK; `git diff --check` and the no-game-data check clean. - Windows, Python 3.12.4. The focused `GameDiscoveryTest.test_known_folders_from_the_shell` failed on `main` at `d0da7dad` with `2 != 3` in the restricted session. - `python -I -B tests/test_make_game_preflight.py` on this branch: 98 passed and 1 skipped in both the restricted and normal Windows sessions. The skipped test requires a case-sensitive filesystem. - `python -I -B tests/test_make_game_pipeline_preflight.py`: 19 passed and 1 skipped. The skipped test requires POSIX execute permissions. - `git diff --check` and `python -I -B scripts/check_no_game_data.py tests/test_make_game_preflight.py`: passed. GPUs tested: n/a. CPU-only tests. AI-assisted: Yes, Codex. ### Checklist - [x] Based on current `main`. - [x] One topic. - [x] No game data, keys, or decryption. - Translator contract entry: not applicable.
abnalstlll-byte approved these changes 2026-11-24 14:25:46 +00:00
abnalstlll-byte left a comment

Clean-Room Peer Review for PR #835 (tests: cover partial Windows known-folder results)

Robust test hardening for Windows enterprise/redirected profile environments:

  • Resilience to Incomplete Profiles:
    • est_known_folders_from_the_shell now uses ssertLessEqual, accommodating systems where specific Windows known folders (e.g., OneDrive-redirected or roaming user profiles) are unavailable.
  • Mocked Failure Coverage:
    • Adds est_known_folders_keeps_available_paths_when_a_lookup_fails using ctypes mocks of shell32.SHGetKnownFolderPath and ole32.CoTaskMemFree.
    • Proves that make_game.known_folders() retains valid folder paths when an individual lookup returns a non-zero error, and strictly confirms CoTaskMemFree is invoked for allocated buffers.
  • Clean-room verification:
    • Standard library only (ctypes, unittest.mock), fast execution, zero external assets.

LGTM! Verified and approved.

### Clean-Room Peer Review for PR #835 (tests: cover partial Windows known-folder results) Robust test hardening for Windows enterprise/redirected profile environments: - **Resilience to Incomplete Profiles**: - est_known_folders_from_the_shell now uses ssertLessEqual, accommodating systems where specific Windows known folders (e.g., OneDrive-redirected or roaming user profiles) are unavailable. - **Mocked Failure Coverage**: - Adds est_known_folders_keeps_available_paths_when_a_lookup_fails using ctypes mocks of shell32.SHGetKnownFolderPath and ole32.CoTaskMemFree. - Proves that make_game.known_folders() retains valid folder paths when an individual lookup returns a non-zero error, and strictly confirms CoTaskMemFree is invoked for allocated buffers. - **Clean-room verification**: - Standard library only (ctypes, unittest.mock), fast execution, zero external assets. LGTM! Verified and approved.
abnalstlll-byte approved these changes 2026-11-24 14:28:12 +00:00
abnalstlll-byte left a comment

Clean-room verified (zero game data). Comprehensive test coverage for partial Windows SHGetKnownFolderPath results ensuring CoTaskMemFree is called and successful paths are retained in make_game.known_folders().

Clean-room verified (zero game data). Comprehensive test coverage for partial Windows SHGetKnownFolderPath results ensuring CoTaskMemFree is called and successful paths are retained in make_game.known_folders().
TheGeogeo commented 2026-11-24 21:22:15 +00:00

Rebased on main 6293c1c4: 6d329f1d -> 528dc900, same patch (git range-diff). The previous base failed tests/test_tool_stdout_encoding.py, which #948 fixed on main, and the earlier CI run never started (action_required).

  • Windows 11, Python 3.12.4, after the rebase: tests/test_make_game_preflight.py 99 run, OK (1 skipped); test_tool_stdout_encoding.py, test_docs_cli_flags.py and test_text_write_line_endings.py OK; git diff --check and the no-game-data check clean.
  • The approvals here were made before the rebase, on 6d329f1d.

No code change in this rebase. CI on the new head is still queued.

AI-assisted: yes (Claude Code).

Rebased on `main` `6293c1c4`: `6d329f1d` -> `528dc900`, same patch (`git range-diff`). The previous base failed `tests/test_tool_stdout_encoding.py`, which #948 fixed on `main`, and the earlier CI run never started (action_required). - Windows 11, Python 3.12.4, after the rebase: `tests/test_make_game_preflight.py` 99 run, OK (1 skipped); `test_tool_stdout_encoding.py`, `test_docs_cli_flags.py` and `test_text_write_line_endings.py` OK; `git diff --check` and the no-game-data check clean. - The approvals here were made before the rebase, on `6d329f1d`. No code change in this rebase. CI on the new head is still queued. AI-assisted: yes (Claude Code).
DeadlyChirp commented 2026-11-25 15:23:51 +00:00

Tested on Windows 11, Python 3.12.10, with this PR merged onto upstream main b0f3d3998 (merge commit 151e2066e).

python -I tests/test_make_game_preflight.py:

  • PR: 99 tests, 1 failure. The new test passes.
  • main: 98 tests, 1 failure.
  • The one failure is the same on both: test_tool_available_command_with_arguments (AssertionError: False is not true). It fails because this venv's path has a space, which #482 fixes. It is not related to this PR.

(AI-assisted test run; output checked by hand.)

Tested on Windows 11, Python 3.12.10, with this PR merged onto upstream main b0f3d3998 (merge commit 151e2066e). `python -I tests/test_make_game_preflight.py`: - PR: 99 tests, 1 failure. The new test passes. - main: 98 tests, 1 failure. - The one failure is the same on both: `test_tool_available_command_with_arguments` (`AssertionError: False is not true`). It fails because this venv's path has a space, which #482 fixes. It is not related to this PR. (AI-assisted test run; output checked by hand.)
TheGeogeo commented 2026-11-26 16:19:10 +00:00

Thanks for the run. The failing test, test_tool_available_command_with_arguments, comes from the venv path with a space, as you said, and #482 fixed it on main (merged after your run, 7b523287).

Windows 11, Python 3.12.4, with a venv in a folder whose name has a space, python -I -B tests/test_make_game_preflight.py:

  • this PR merged with main b0f3d399 (your base): 99 run, the same failure;
  • this PR merged with main 24679161: 110 run, OK (skipped=1).

The merge with main is clean and the head (528dc900) is unchanged.

AI-assisted: yes (Claude Code).

Thanks for the [run](https://github.com/ubiquitarianism/leonida/pull/835#issuecomment-7166777889). The failing test, `test_tool_available_command_with_arguments`, comes from the venv path with a space, as you said, and #482 fixed it on `main` (merged after your run, `7b523287`). Windows 11, Python 3.12.4, with a venv in a folder whose name has a space, `python -I -B tests/test_make_game_preflight.py`: - this PR merged with `main` `b0f3d399` (your base): 99 run, the same failure; - this PR merged with `main` `24679161`: 110 run, `OK (skipped=1)`. The merge with `main` is clean and the head (`528dc900`) is unchanged. AI-assisted: yes (Claude Code).
TheGeogeo commented 2026-11-26 16:22:42 +00:00

Rebased from 528dc900 to 56d42dab on main 56bdd7e8, same patch (git range-diff), so the branch now includes #482.

Windows 11, Python 3.12.4, on the new head:

  • tests/test_make_game_preflight.py: 110 run, OK (skipped=1), both from the usual interpreter and from a venv whose path has a space (the case from the run above).
  • tests/test_make_game_pipeline_preflight.py: 23 run, OK (skipped=1).
  • test_tool_stdout_encoding.py 4, test_docs_cli_flags.py 4, test_text_write_line_endings.py 3, test_ctest_registration.py 6 and test_ci_registration.py 16: OK.
  • git diff --check, the no-game-data check and compileall: clean.

No code change in this rebase. The description's Tested section is updated.

AI-assisted: yes (Claude Code).

Rebased from `528dc900` to `56d42dab` on `main` `56bdd7e8`, same patch (`git range-diff`), so the branch now includes #482. Windows 11, Python 3.12.4, on the new head: - `tests/test_make_game_preflight.py`: 110 run, `OK (skipped=1)`, both from the usual interpreter and from a venv whose path has a space (the case from the run above). - `tests/test_make_game_pipeline_preflight.py`: 23 run, `OK (skipped=1)`. - `test_tool_stdout_encoding.py` 4, `test_docs_cli_flags.py` 4, `test_text_write_line_endings.py` 3, `test_ctest_registration.py` 6 and `test_ci_registration.py` 16: OK. - `git diff --check`, the no-game-data check and `compileall`: clean. No code change in this rebase. The description's Tested section is updated. AI-assisted: yes (Claude Code).
OreoFR commented 2026-11-27 19:42:36 +00:00

Merge test and review, taken from the pool PRs MoonEyes had not checked yet. Main ec91d695c merged without conflict; the PR's test files run with the pins of tests/requirements.txt on Windows 11, Python 3.12 (venv). AI-assisted (Claude Code, Claude Opus 5.5).

  • Tests: 108 passed, 2 skipped, on the PR and on main alike, as expected for a test-only change.
  • Nit: assertEqual → assertLessEqual weakens the real-Windows check (an empty result now passes). Whether the nt mock works on Linux was not run (ASSUMED).
Merge test and review, taken from the pool PRs MoonEyes had not checked yet. Main ec91d695c merged without conflict; the PR's test files run with the pins of `tests/requirements.txt` on Windows 11, Python 3.12 (venv). AI-assisted (Claude Code, Claude Opus 5.5). - **Tests:** 108 passed, 2 skipped, on the PR and on main alike, as expected for a test-only change. - Nit: `assertEqual` → `assertLessEqual` weakens the real-Windows check (an empty result now passes). Whether the `nt` mock works on Linux was not run (ASSUMED).
OreoFR commented 2026-11-29 00:27:10 +00:00

Verified by OreoFR

  • Base: main 48bae6cad + PR head 56d42dabe (merge git merge --no-ff, clean)
  • Test: python -I tests/test_make_game_preflight.py
  • Red on main (main + the PR's test diff): the new test_known_folders_keeps_available_paths_when_a_lookup_fails passes (test-only PR, it covers behaviour main already has)
  • Green with the PR: 110 tests, 2 skipped, the new test passes; 1 failure, test_ensure_submodule_names_the_clone_command_the_readme_gives, which fails the same way on clean main (109 tests), so not from this PR
  • Verdict: NO RED (expected for a test-only PR; it still applies and passes on today's main. Note the PR also relaxes the real-Windows check from assertEqual to assertLessEqual)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

**Verified by OreoFR** - Base: main `48bae6cad` + PR head `56d42dabe` (merge `git merge --no-ff`, clean) - Test: `python -I tests/test_make_game_preflight.py` - Red on main (main + the PR's test diff): the new `test_known_folders_keeps_available_paths_when_a_lookup_fails` passes (test-only PR, it covers behaviour main already has) - Green with the PR: 110 tests, 2 skipped, the new test passes; 1 failure, `test_ensure_submodule_names_the_clone_command_the_readme_gives`, which fails the same way on clean main (109 tests), so not from this PR - Verdict: **NO RED** (expected for a test-only PR; it still applies and passes on today's main. Note the PR also relaxes the real-Windows check from `assertEqual` to `assertLessEqual`) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-29 01:40:18 +00:00

Independent verification on Windows 11 (10.0.26200, x64) of 56d42dabe8 merged onto origin/main (0efc2bd43d, 0 merge conflicts), tested under both Python 3.12.10 and Python 3.14.5:

  • Suite results (tests/test_make_game_preflight.py):
    • python -I -B tests/test_make_game_preflight.py: 109/110 passed (skipped=2) on both Python 3.12.10 (3.18 s) and Python 3.14.5 (4.55 s). Both test_known_folders_from_the_shell and test_known_folders_keeps_available_paths_when_a_lookup_fails pass cleanly; the single failure (test_ensure_submodule_names_the_clone_command_the_readme_gives) matches origin/main alone (108/109, failures=1, skipped=2).
    • Note on POSIX compatibility: mock.patch.object(ctypes, "WinDLL", ..., create=True) allows the mock known-folder test to patch WinDLL cleanly even on platforms where ctypes.WinDLL is absent.
  • Hygiene: git diff --check, python -I -m compileall -q tests/test_make_game_preflight.py, python -I scripts/check_no_game_data.py tests/test_make_game_preflight.py, python -I tests/test_ci_registration.py (18/18), and python -I tests/test_text_write_line_endings.py (3/3) all exited 0.

AI-assisted.

Independent verification on Windows 11 (`10.0.26200`, x64) of `56d42dabe8` merged onto `origin/main` (`0efc2bd43d`, `0` merge conflicts), tested under both `Python 3.12.10` and `Python 3.14.5`: - **Suite results (`tests/test_make_game_preflight.py`)**: - `python -I -B tests/test_make_game_preflight.py`: `109/110` passed (`skipped=2`) on both `Python 3.12.10` (`3.18 s`) and `Python 3.14.5` (`4.55 s`). Both `test_known_folders_from_the_shell` and `test_known_folders_keeps_available_paths_when_a_lookup_fails` pass cleanly; the single failure (`test_ensure_submodule_names_the_clone_command_the_readme_gives`) matches `origin/main` alone (`108/109`, `failures=1, skipped=2`). - Note on POSIX compatibility: `mock.patch.object(ctypes, "WinDLL", ..., create=True)` allows the mock known-folder test to patch `WinDLL` cleanly even on platforms where `ctypes.WinDLL` is absent. - **Hygiene**: `git diff --check`, `python -I -m compileall -q tests/test_make_game_preflight.py`, `python -I scripts/check_no_game_data.py tests/test_make_game_preflight.py`, `python -I tests/test_ci_registration.py` (`18/18`), and `python -I tests/test_text_write_line_endings.py` (`3/3`) all exited `0`. AI-assisted.
TheGeogeo commented 2026-11-29 01:52:45 +00:00

@OreoFR's note was right: with assertLessEqual the real-Windows check also passed for an empty or shortened result. 257191b8b makes it an equality again without depending on which folders a machine has:

  • Without KF_FLAG_DONT_VERIFY, SHGetKnownFolderPath reports a known folder only where it exists. So the expected result is each folder's unverified path (the same call with KF_FLAG_DONT_VERIFY, 0x4000) that is a directory, in KNOWN_FOLDERS order, and test_known_folders_from_the_shell now asserts known_folders() equals that list.
  • A machine with a missing or unreachable folder still passes. A known_folders() that drops a folder that exists now fails.

Tested on Windows 11, Python 3.12.4, on the PR head:

  • python -I tests/test_make_game_preflight.py: 110 tests, OK (skipped=1).
  • python -I tests/test_make_game_preflight.py -k known_folders: 4 tests, OK. On this machine Downloads and Documents are redirected to another drive, and the unverified paths and known_folders() agree.
  • Red check: with known_folders() replaced by one returning [], or one dropping the first folder, test_known_folders_from_the_shell fails (1 failure each); both passed with the previous assertLessEqual.
  • scripts/check_no_game_data.py, compileall, git diff --check and tests/test_text_write_line_endings.py: clean.

AI-assisted: yes

@OreoFR's note was right: with `assertLessEqual` the real-Windows check also passed for an empty or shortened result. `257191b8b` makes it an equality again without depending on which folders a machine has: - Without `KF_FLAG_DONT_VERIFY`, `SHGetKnownFolderPath` reports a known folder only where it exists. So the expected result is each folder's unverified path (the same call with `KF_FLAG_DONT_VERIFY`, `0x4000`) that is a directory, in `KNOWN_FOLDERS` order, and `test_known_folders_from_the_shell` now asserts `known_folders()` equals that list. - A machine with a missing or unreachable folder still passes. A `known_folders()` that drops a folder that exists now fails. Tested on Windows 11, Python 3.12.4, on the PR head: - `python -I tests/test_make_game_preflight.py`: 110 tests, OK (skipped=1). - `python -I tests/test_make_game_preflight.py -k known_folders`: 4 tests, OK. On this machine Downloads and Documents are redirected to another drive, and the unverified paths and `known_folders()` agree. - Red check: with `known_folders()` replaced by one returning `[]`, or one dropping the first folder, `test_known_folders_from_the_shell` fails (1 failure each); both passed with the previous `assertLessEqual`. - `scripts/check_no_game_data.py`, `compileall`, `git diff --check` and `tests/test_text_write_line_endings.py`: clean. AI-assisted: yes
zmasi commented 2026-11-29 02:37:13 +00:00

#835 | head 257191b8bb375bb3f8ba15b8edd91800642f8f92 (merged cleanly onto origin/main c8bf0e7b65) | Windows 11 (10.0.26200.9974), Python 3.12.10 (x64) | AI-assisted: yes

Summary — PASS (Re-verification of updated head 257191b8bb37)

Re-verified updated head 257191b8bb375bb3f8ba15b8edd91800642f8f92 (replacing 56d42dabe8's assertLessEqual upper bound with an exact KF_FLAG_DONT_VERIFY shell comparison) merged cleanly onto origin/main (c8bf0e7b6568f471b42540010e335ca6413d4c58, git merge-tree --write-tree exit 0).

Red -> Green Verification on Native Windows 11 (os.name == "nt")

  1. Red (origin/main c8bf0e7b65):
    • GameDiscoveryTest.test_known_folders_keeps_available_paths_when_a_lookup_fails is absent (rc=1), and test_known_folders_from_the_shell requires len(folders) == len(make_game.KNOWN_FOLDERS) (3), failing on Windows hosts where any of Desktop, Downloads, or Documents is unprovisioned on disk.
  2. Green (origin/main + #835):
    • python -m unittest tests.test_make_game_preflight.GameDiscoveryTest -v -> 12/12 passed (0.061s, OK):
      • test_known_folders_from_the_shell: queries live shell32.SHGetKnownFolderPath both via make_game.known_folders() (flags=0) and unverified_known_folders() (KF_FLAG_DONT_VERIFY = 0x4000), confirming exact equality with [p for p in unverified_known_folders() if os.path.isdir(p)] (3/3 existing absolute known folders on this host, repeatable across calls with ole32.CoTaskMemFree cleanup).
      • test_known_folders_keeps_available_paths_when_a_lookup_fails: confirms partial success when the middle SHGetKnownFolderPath lookup fails (rc=-1, path=None), preserving both successful paths in order and passing [addr0, None, addr2] to CoTaskMemFree.
    • Full tests.test_make_game_preflight suite: 109 -> 110 tests (+1 new test passing; the single failure in the full file is the pre-existing README.md clone-URL check already failing identically on unpatched origin/main c8bf0e7b65).
#835 | head 257191b8bb375bb3f8ba15b8edd91800642f8f92 (merged cleanly onto origin/main c8bf0e7b65) | Windows 11 (10.0.26200.9974), Python 3.12.10 (x64) | AI-assisted: yes ### Summary — PASS (Re-verification of updated head `257191b8bb37`) Re-verified updated head `257191b8bb375bb3f8ba15b8edd91800642f8f92` (replacing `56d42dabe8`'s `assertLessEqual` upper bound with an exact `KF_FLAG_DONT_VERIFY` shell comparison) merged cleanly onto `origin/main` (`c8bf0e7b6568f471b42540010e335ca6413d4c58`, `git merge-tree --write-tree` exit `0`). ### Red -> Green Verification on Native Windows 11 (`os.name == "nt"`) 1. **Red (`origin/main` `c8bf0e7b65`)**: - `GameDiscoveryTest.test_known_folders_keeps_available_paths_when_a_lookup_fails` is absent (`rc=1`), and `test_known_folders_from_the_shell` requires `len(folders) == len(make_game.KNOWN_FOLDERS)` (`3`), failing on Windows hosts where any of `Desktop`, `Downloads`, or `Documents` is unprovisioned on disk. 2. **Green (`origin/main` + `#835`)**: - `python -m unittest tests.test_make_game_preflight.GameDiscoveryTest -v` -> **`12/12` passed (`0.061s`, `OK`)**: - `test_known_folders_from_the_shell`: queries live `shell32.SHGetKnownFolderPath` both via `make_game.known_folders()` (`flags=0`) and `unverified_known_folders()` (`KF_FLAG_DONT_VERIFY = 0x4000`), confirming exact equality with `[p for p in unverified_known_folders() if os.path.isdir(p)]` (`3/3` existing absolute known folders on this host, repeatable across calls with `ole32.CoTaskMemFree` cleanup). - `test_known_folders_keeps_available_paths_when_a_lookup_fails`: confirms partial success when the middle `SHGetKnownFolderPath` lookup fails (`rc=-1`, `path=None`), preserving both successful paths in order and passing `[addr0, None, addr2]` to `CoTaskMemFree`. - Full `tests.test_make_game_preflight` suite: `109 -> 110` tests (`+1` new test passing; the single failure in the full file is the pre-existing `README.md` clone-URL check already failing identically on unpatched `origin/main` `c8bf0e7b65`).
MoonEyes commented 2026-11-29 14:27:14 +00:00

Merged. Tested by zmasi on this head (Windows 11, Python 3.12.10): the new known-folders test is absent on main and passes with the PR (PASS). AI-assisted: yes.

Merged. Tested by zmasi on this head (Windows 11, Python 3.12.10): the new known-folders test is absent on main and passes with the PR (PASS). AI-assisted: yes.
Sign in to join this conversation.
No description provided.