Skip to content

Commit cd3511e

Browse files
committed
test(self-update): ensure the resolution of #3739
1 parent ab8975f commit cd3511e

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

tests/suite/cli_self_upd.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ use rustup::utils::{raw, utils};
2323
use rustup::{for_host, DUP_TOOLS, TOOLS};
2424
use rustup_macros::integration_test as test;
2525

26+
#[cfg(windows)]
27+
use rustup::test::with_saved_programs_display_version;
28+
2629
const TEST_VERSION: &str = "1.1.1";
2730

2831
pub fn update_setup(f: &dyn Fn(&mut Config, &Path)) {
@@ -304,7 +307,41 @@ info: downloading self-update
304307
&["rustup", "self", "update"],
305308
&format!(" rustup updated - {version} (from {version})\n\n",),
306309
&expected_output,
307-
)
310+
);
311+
});
312+
}
313+
314+
#[test]
315+
#[cfg(windows)]
316+
fn update_overwrites_programs_display_version() {
317+
const RUSTUP_UNINSTALL_ENTRY: &str =
318+
r"Software\Microsoft\Windows\CurrentVersion\Uninstall\Rustup";
319+
320+
const PLACEHOLDER_VERSION: &str = "9.999.99";
321+
let version = env!("CARGO_PKG_VERSION");
322+
323+
update_setup(&|config, _| {
324+
with_saved_programs_display_version(&mut || {
325+
config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]);
326+
327+
winreg::RegKey::predef(winreg::enums::HKEY_CURRENT_USER)
328+
.create_subkey(RUSTUP_UNINSTALL_ENTRY)
329+
.unwrap()
330+
.0
331+
.set_value("DisplayVersion", &PLACEHOLDER_VERSION)
332+
.unwrap();
333+
334+
config.expect_ok(&["rustup", "self", "update"]);
335+
336+
assert_eq!(
337+
winreg::RegKey::predef(winreg::enums::HKEY_CURRENT_USER)
338+
.open_subkey(RUSTUP_UNINSTALL_ENTRY)
339+
.unwrap()
340+
.get_value::<String, _>("DisplayVersion")
341+
.unwrap(),
342+
version,
343+
);
344+
});
308345
});
309346
}
310347

0 commit comments

Comments
 (0)