F1 menu tests: the variables they change come back, also on a failed assertion #2500

Closed
breachato wants to merge 14 commits from upstream-pr/2500 into main
breachato commented 2026-11-29 13:42:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by breachato on 2026-11-29T13:42:05Z.


[pr-tests]

What it changes

Updated after main moved: main now has test_env_lock() and takes it in the shadow-lift test, which fixes the race this PR first addressed (5 of 5 parallel runs failed on 829188e; on today's main they pass). What is left is the point raised in review:

  • a_change_is_saved_at_once_however_the_game_was_started removes VICTORY_MENU_FILE and points VICTORY_HOME at a folder it deletes at the end, and puts neither back. A later test in the same process then saves into that deleted folder.
  • vehicle_auto_center_zero_is_normalized_to_off sets VICTORY_VEHICLE_AUTO_CENTER without the lock and restores it by hand after its assertions, so a failed assertion leaves it set.

This moves the shadow-lift test's Restore guard to the test module (Restore::saving(&[...])) and takes it right after test_env_lock() in those three tests. The vehicle test now takes the lock too. Values, or their absence, come back before the lock is released, even when an assertion unwinds. Test-only; no runtime code changes.

How it was tested

  • cargo test -p victory-gpu --lib --locked host::menu::tests, Windows 11, toolchain 1.98.1: 28 passed, 3 of 3 parallel runs, and with --test-threads=1.
  • cargo test passed for the crates it touches: yes (the menu tests; nothing else changes)

How to try it

cargo test -p victory-gpu --lib --locked host::menu::tests, in parallel and with -- --test-threads=1: 28 pass both ways. The change is in the tests module only.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2495 touches menu.rs too (help text only, no shared lines).

Assisted by Claude.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5551287274 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2500). Originally posted by [breachato](https://github.com/breachato) on 2026-11-29T13:42:05Z. --- [pr-tests] ## What it changes Updated after `main` moved: `main` now has `test_env_lock()` and takes it in the shadow-lift test, which fixes the race this PR first addressed (5 of 5 parallel runs failed on 829188e; on today's `main` they pass). What is left is the point raised in review: - `a_change_is_saved_at_once_however_the_game_was_started` removes `VICTORY_MENU_FILE` and points `VICTORY_HOME` at a folder it deletes at the end, and puts neither back. A later test in the same process then saves into that deleted folder. - `vehicle_auto_center_zero_is_normalized_to_off` sets `VICTORY_VEHICLE_AUTO_CENTER` without the lock and restores it by hand after its assertions, so a failed assertion leaves it set. This moves the shadow-lift test's `Restore` guard to the test module (`Restore::saving(&[...])`) and takes it right after `test_env_lock()` in those three tests. The vehicle test now takes the lock too. Values, or their absence, come back before the lock is released, even when an assertion unwinds. Test-only; no runtime code changes. ## How it was tested - `cargo test -p victory-gpu --lib --locked host::menu::tests`, Windows 11, toolchain 1.98.1: 28 passed, 3 of 3 parallel runs, and with `--test-threads=1`. - `cargo test` passed for the crates it touches: yes (the menu tests; nothing else changes) ## How to try it `cargo test -p victory-gpu --lib --locked host::menu::tests`, in parallel and with `-- --test-threads=1`: 28 pass both ways. The change is in the tests module only. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2495 touches `menu.rs` too (help text only, no shared lines). Assisted by Claude.
ANDREANIADS commented 2026-11-29 13:58:00 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ANDREANIADS on 2026-11-29T13:58:00Z.


At 43658ea the three tests take the same mutex. One isolation detail survives even with a single test thread: a_change_is_saved_at_once_however_the_game_was_started removes VICTORY_MENU_FILE and replaces VICTORY_HOME, then deletes the temporary directory without restoring either variable. In a synthetic process seeded with both values, repeating just those two environment operations under a lock and reacquiring it yielded (unset, temporary-home). This checks state lifetime only; I did not run the Windows suite.

Could the test reuse the gray-shadow test’s Restore guard for both keys? Declare it after acquiring _env so the original values (including absence) are restored before unlocking, even if an assertion unwinds.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7256936368 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2500#issuecomment-7256936368). Originally posted by [ANDREANIADS](https://github.com/ANDREANIADS) on 2026-11-29T13:58:00Z. --- At `43658ea` the three tests take the same mutex. One isolation detail survives even with a single test thread: `a_change_is_saved_at_once_however_the_game_was_started` removes `VICTORY_MENU_FILE` and replaces `VICTORY_HOME`, then deletes the temporary directory without restoring either variable. In a synthetic process seeded with both values, repeating just those two environment operations under a lock and reacquiring it yielded `(unset, temporary-home)`. This checks state lifetime only; I did not run the Windows suite. Could the test reuse the gray-shadow test’s `Restore` guard for both keys? Declare it after acquiring `_env` so the original values (including absence) are restored before unlocking, even if an assertion unwinds.
breachato commented 2026-11-29 17:32:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by breachato on 2026-11-29T17:32:39Z.


Good catch, thanks. Done in fbe67fd: Restore now lives in the test module, and all three tests take it right after env_lock() (VICTORY_MENU_FILE + VICTORY_HOME in a_change_…, VICTORY_VEHICLE_AUTO_CENTER in the vehicle test). The values, or their absence, come back before the lock is released, also on unwind. The menu tests pass in parallel (3/3) and with --test-threads=1.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7259774387 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2500#issuecomment-7259774387). Originally posted by [breachato](https://github.com/breachato) on 2026-11-29T17:32:39Z. --- Good catch, thanks. Done in fbe67fd: `Restore` now lives in the test module, and all three tests take it right after `env_lock()` (`VICTORY_MENU_FILE` + `VICTORY_HOME` in `a_change_…`, `VICTORY_VEHICLE_AUTO_CENTER` in the vehicle test). The values, or their absence, come back before the lock is released, also on unwind. The menu tests pass in parallel (3/3) and with `--test-threads=1`.
breachato commented 2026-12-01 13:59:26 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by breachato on 2026-12-01T13:59:26Z.


Closing: the menu tests this fixed were removed from menu.rs in 3bde4923 (#4634), so there is nothing left to restore.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7313515467 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2500#issuecomment-7313515467). Originally posted by [breachato](https://github.com/breachato) on 2026-12-01T13:59:26Z. --- Closing: the menu tests this fixed were removed from `menu.rs` in 3bde4923 (#4634), so there is nothing left to restore.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!2500
No description provided.