Skip to content

Commit 3dee2da

Browse files
committed
test(self-update): ensure the resolution of #3739
1 parent a688e2d commit 3dee2da

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

tests/suite/cli_self_upd.rs

+37-1
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_reg_value;
28+
2629
const TEST_VERSION: &str = "1.1.1";
2730

2831
pub fn update_setup(f: &dyn Fn(&mut Config, &Path)) {
@@ -304,7 +307,40 @@ 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+
let root = &winreg::RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
318+
let key = r"Software\Microsoft\Windows\CurrentVersion\Uninstall\Rustup";
319+
let name = "DisplayVersion";
320+
321+
const PLACEHOLDER_VERSION: &str = "9.999.99";
322+
let version = env!("CARGO_PKG_VERSION");
323+
324+
update_setup(&|config, _| {
325+
with_saved_reg_value(root, key, name, &mut || {
326+
config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]);
327+
328+
root.create_subkey(key)
329+
.unwrap()
330+
.0
331+
.set_value(name, &PLACEHOLDER_VERSION)
332+
.unwrap();
333+
334+
config.expect_ok(&["rustup", "self", "update"]);
335+
336+
assert_eq!(
337+
root.open_subkey(key)
338+
.unwrap()
339+
.get_value::<String, _>(name)
340+
.unwrap(),
341+
version,
342+
);
343+
});
308344
});
309345
}
310346

0 commit comments

Comments
 (0)