Skip to content

Commit 9e9a2dc

Browse files
committed
Log versions during self updates
1 parent 34303ab commit 9e9a2dc

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/cli/self_update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ pub(crate) async fn prepare_update(process: &Process) -> Result<Option<PathBuf>>
11381138
let current_version = env!("CARGO_PKG_VERSION");
11391139

11401140
// Get available version
1141-
info!("checking for self-update");
1141+
info!("checking for self-update (current version: {current_version})");
11421142
let available_version = if let Some(ver) = non_empty_env_var("RUSTUP_VERSION", process)? {
11431143
info!("`RUSTUP_VERSION` has been set to `{ver}`");
11441144
ver
@@ -1158,7 +1158,7 @@ pub(crate) async fn prepare_update(process: &Process) -> Result<Option<PathBuf>>
11581158
let download_url = utils::parse_url(&url)?;
11591159

11601160
// Download new version
1161-
info!("downloading self-update");
1161+
info!("downloading self-update (new version: {available_version})");
11621162
download_file(&download_url, &setup_path, None, &|_| (), process).await?;
11631163

11641164
// Mark as executable

tests/suite/cli_exact.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ info: installing component 'rustc'
8383
#[tokio::test]
8484
async fn update_once_and_self_update() {
8585
let test_version = "2.0.0";
86+
let current = env!("CARGO_PKG_VERSION");
8687
let mut cx = CliTestContext::new(Scenario::SimpleV2).await;
8788
let _dist_guard = cx.with_update_server(test_version);
8889
cx.config
@@ -111,8 +112,8 @@ info: installing component 'cargo'
111112
info: installing component 'rust-docs'
112113
info: installing component 'rust-std'
113114
info: installing component 'rustc'
114-
info: checking for self-update
115-
info: downloading self-update
115+
info: checking for self-update (current version: {current})
116+
info: downloading self-update (new version: 2.0.0)
116117
"
117118
),
118119
)

tests/suite/cli_self_upd.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,11 @@ struct GcErr(Vec<String>);
367367
#[tokio::test]
368368
async fn update_exact() {
369369
let version = env!("CARGO_PKG_VERSION");
370-
let expected_output = "info: checking for self-update
371-
info: downloading self-update
370+
let expected_output = format!(
371+
"info: checking for self-update (current version: {version})
372+
info: downloading self-update (new version: {TEST_VERSION})
372373
"
373-
.to_string();
374+
);
374375

375376
let mut cx = SelfUpdateTestContext::new(TEST_VERSION).await;
376377
cx.config
@@ -389,9 +390,9 @@ info: downloading self-update
389390
async fn update_precise() {
390391
let version = env!("CARGO_PKG_VERSION");
391392
let expected_output = format!(
392-
"info: checking for self-update
393+
"info: checking for self-update (current version: {version})
393394
info: `RUSTUP_VERSION` has been set to `{TEST_VERSION}`
394-
info: downloading self-update
395+
info: downloading self-update (new version: {TEST_VERSION})
395396
"
396397
);
397398

@@ -563,8 +564,10 @@ async fn update_no_change() {
563564
564565
"
565566
),
566-
r"info: checking for self-update
567-
",
567+
&format!(
568+
r"info: checking for self-update (current version: {version})
569+
"
570+
),
568571
)
569572
.await;
570573
}
@@ -628,6 +631,7 @@ async fn rustup_no_self_update_with_specified_toolchain() {
628631

629632
#[tokio::test]
630633
async fn rustup_self_update_exact() {
634+
let version = env!("CARGO_PKG_VERSION");
631635
let mut cx = SelfUpdateTestContext::new(TEST_VERSION).await;
632636
cx.config
633637
.expect_ok(&["rustup", "set", "auto-self-update", "enable"])
@@ -647,8 +651,8 @@ async fn rustup_self_update_exact() {
647651
),
648652
for_host!(
649653
r"info: syncing channel updates for 'stable-{0}'
650-
info: checking for self-update
651-
info: downloading self-update
654+
info: checking for self-update (current version: {version})
655+
info: downloading self-update (new version: {TEST_VERSION})
652656
info: cleaning up downloads & tmp directories
653657
"
654658
),

0 commit comments

Comments
 (0)