Skip to content

Commit 5bccc07

Browse files
committed
feat(test): isolate Windows registry state per test
1 parent a79e280 commit 5bccc07

9 files changed

Lines changed: 253 additions & 122 deletions

File tree

src/cli/self_update.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ pub(crate) use unix::{run_update, self_replace};
9191
mod windows;
9292
#[cfg(windows)]
9393
pub use windows::complete_windows_uninstall;
94+
#[cfg(all(windows, any(test, feature = "test")))]
95+
pub(crate) use windows::test_id;
9496
#[cfg(all(windows, feature = "test"))]
95-
pub use windows::{RegistryGuard, RegistryValueId, USER_PATH, get_path};
97+
pub use windows::{RUSTUP_TEST_REGISTRY_UUID, RegistryValueId, USER_PATH, get_path};
9698
#[cfg(windows)]
9799
use windows::{do_add_to_path, do_add_to_programs, do_remove_from_path, do_remove_from_programs};
98100
#[cfg(windows)]
@@ -505,7 +507,7 @@ impl SelfUpdateMode {
505507
let setup_path = prepare_update(dl_cfg).await?;
506508

507509
if let Some(setup_path) = &setup_path {
508-
return run_update(setup_path);
510+
return run_update(setup_path, dl_cfg.process);
509511
} else {
510512
// Try again in case we emitted "tool `{}` is already installed" last time.
511513
install_proxies(dl_cfg.process)?;
@@ -1019,7 +1021,7 @@ fn clean_cargo_home(no_modify_path: bool, process: &Process) -> Result<()> {
10191021
utils::remove_file("rustup_bin", &rustup_path)?;
10201022

10211023
#[cfg(windows)]
1022-
do_remove_from_programs()?;
1024+
do_remove_from_programs(process)?;
10231025

10241026
let cargo_bin_display = cargo_bin.display();
10251027
info!("removing empty cargo bin directory `{cargo_bin_display}`");
@@ -1146,7 +1148,7 @@ pub(crate) async fn update(cfg: &Cfg<'_>) -> Result<ExitCode> {
11461148
PackageUpdate::Rustup,
11471149
Ok(UpdateStatus::Updated(version)),
11481150
);
1149-
return run_update(&setup_path);
1151+
return run_update(&setup_path, cfg.process);
11501152
}
11511153
None => {
11521154
let _ = common::show_channel_update(

src/cli/self_update/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub(crate) fn do_write_env_files(process: &Process) -> Result<()> {
117117

118118
/// Tell the upgrader to replace the rustup bins, then delete
119119
/// itself.
120-
pub(crate) fn run_update(setup_path: &Path) -> Result<utils::ExitCode> {
120+
pub(crate) fn run_update(setup_path: &Path, _process: &Process) -> Result<utils::ExitCode> {
121121
let status = Command::new(setup_path)
122122
.arg("--self-replace")
123123
.status()

0 commit comments

Comments
 (0)