Skip to content

fix(test): test delete Windows registry accidently#4917

Closed
baka-gourd wants to merge 10 commits into
rust-lang:mainfrom
baka-gourd:windows-registry
Closed

fix(test): test delete Windows registry accidently#4917
baka-gourd wants to merge 10 commits into
rust-lang:mainfrom
baka-gourd:windows-registry

Conversation

@baka-gourd

@baka-gourd baka-gourd commented Jun 21, 2026

Copy link
Copy Markdown

fix #4915

This PR is intended to fix the issue mentioned in the ticket regarding the accidental deletion of existing registry entries. However, while investigating the problem, we also discovered a concurrency issue in RegistryGuard, so the scope of the fix is quite extensive.

Changes:

  • Add per-test-process Windows registry isolation using a unique test UUID.
  • Refactor registry helpers to create, resolve, and clean test-specific registry keys safely.
  • Update RegistryGuard to support multiple registry values and improve cleanup behavior.
  • Separate PATH updates from Programs entry updates during install and uninstall.
  • Ensure do_add_to_path and do_remove_from_path only modify PATH.
  • Ensure do_add_to_programs and do_remove_from_programs only modify Programs entries.
  • Update Windows tests to use the new registry helpers and RegistryGuard::new API.
  • Add tests verifying PATH and Programs registry changes remain independent.
  • Treat missing registry keys or values as non-fatal during cleanup.

No new UUID library has been introduced at this time; if needed,can use uuid create.

…ove_from_path()`

BREAKING CHANGE: Windows registry cleanup is no longer performed by `do_remove_from_path()`.

Co-authored-by: baka-gourd <36119339+baka-gourd@users.noreply.github.com>
BREAKING CHANGE: `do_add_to_path()` will not add Windows registry
On Windows, fall back to `OpenMutexW` when `CreateMutexW` hits `ERROR_ACCESS_DENIED` for an existing registry guard mutex. This lets concurrent test processes wait on the shared mutex instead of failing during guard construction.
Also update PATH registry tests for UUID-isolated roots, where the initial PATH may be absent and uninstall may correctly restore it to `None`.
On Windows, fall back to `OpenMutexW` when `CreateMutexW` hits `ERROR_ACCESS_DENIED` for an existing registry guard mutex. This lets concurrent test processes wait on the shared mutex instead of failing during guard construction.
Also update PATH registry tests for UUID-isolated roots, where the initial PATH may be absent and uninstall may correctly restore it to `None`.
@baka-gourd baka-gourd marked this pull request as draft June 21, 2026 08:30
@baka-gourd baka-gourd closed this Jun 21, 2026
@baka-gourd baka-gourd deleted the windows-registry branch June 21, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Current tests run on Windows will accidently clears installed registry values by normal installation of rustup

1 participant