Skip to content

Commit aa060cd

Browse files
LeSeulArtichautkinnison
authored andcommitted
Add component name when target is not equal to host
1 parent b67ed1d commit aa060cd

File tree

4 files changed

+83
-7
lines changed

4 files changed

+83
-7
lines changed

src/dist/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ fn update_from_dist_<'a>(
689689

690690
if let ErrorKind::RequestedComponentsUnavailable(components, ..) = e.kind() {
691691
(download.notify_handler)(Notification::SkippingNightlyMissingComponent(
692-
components,
692+
&toolchain, components,
693693
));
694694

695695
if first_err.is_none() {

src/dist/notifications.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::config::PgpPublicKey;
2-
use crate::dist::dist::TargetTriple;
2+
use crate::dist::dist::{TargetTriple, ToolchainDesc};
33
use crate::dist::manifest::Component;
44
use crate::dist::temp;
55
use crate::errors::*;
@@ -31,7 +31,7 @@ pub enum Notification<'a> {
3131
DownloadingManifest(&'a str),
3232
DownloadedManifest(&'a str, Option<&'a str>),
3333
DownloadingLegacyManifest,
34-
SkippingNightlyMissingComponent(&'a [Component]),
34+
SkippingNightlyMissingComponent(&'a ToolchainDesc, &'a [Component]),
3535
ForcingUnavailableComponent(&'a str),
3636
ManifestChecksumFailedHack,
3737
ComponentUnavailable(&'a str, Option<&'a TargetTriple>),
@@ -72,7 +72,7 @@ impl<'a> Notification<'a> {
7272
| ManifestChecksumFailedHack
7373
| RollingBack
7474
| DownloadingManifest(_)
75-
| SkippingNightlyMissingComponent(_)
75+
| SkippingNightlyMissingComponent(_, _)
7676
| RetryingDownload(_)
7777
| DownloadedManifest(_, _) => NotificationLevel::Info,
7878
CantReadUpdateHash(_)
@@ -174,13 +174,19 @@ impl<'a> Display for Notification<'a> {
174174
"removing stray hash found at '{}' in order to continue",
175175
path.display()
176176
),
177-
SkippingNightlyMissingComponent(components) => write!(
177+
SkippingNightlyMissingComponent(toolchain, components) => write!(
178178
f,
179179
"skipping nightly which is missing installed component{} '{}'",
180180
if components.len() > 1 { "s" } else { "" },
181181
components
182182
.iter()
183-
.map(|component| component.short_name_in_manifest().to_owned())
183+
.map(|component| {
184+
if component.target.as_ref() != Some(&toolchain.target) {
185+
component.name_in_manifest().to_owned()
186+
} else {
187+
component.short_name_in_manifest().to_owned()
188+
}
189+
})
184190
.collect::<Vec<_>>()
185191
.join("', '")
186192
),

tests/cli-exact.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,62 @@ fn install_by_version_number() {
533533
expect_ok(config, &["rustup", "default", "0.100.99"]);
534534
})
535535
}
536+
537+
// issue #2191
538+
#[test]
539+
fn install_unreleased_component() {
540+
clitools::setup(Scenario::MissingComponentMulti, &|config| {
541+
// Initial channel content is host + rls + multiarch-std
542+
set_current_dist_date(config, "2019-09-12");
543+
expect_ok(config, &["rustup", "default", "nightly"]);
544+
expect_ok(config, &["rustup", "component", "add", "rls"]);
545+
expect_ok(config, &["rustup", "target", "add", clitools::MULTI_ARCH1]);
546+
547+
// Next channel variant should have host + rls but not multiarch-std
548+
set_current_dist_date(config, "2019-09-13");
549+
expect_ok_ex(
550+
config,
551+
&["rustup", "update", "nightly", "--no-self-update"],
552+
&for_host!(
553+
r"
554+
nightly-{} unchanged - 1.37.0 (hash-nightly-1)
555+
556+
"
557+
),
558+
&format!(
559+
r"info: syncing channel updates for 'nightly-{0}'
560+
info: latest update on 2019-09-13, rust version 1.37.0 (hash-nightly-2)
561+
info: skipping nightly which is missing installed component 'rust-std-{1}'
562+
info: syncing channel updates for 'nightly-2019-09-12-{0}'
563+
",
564+
clitools::this_host_triple(),
565+
clitools::MULTI_ARCH1
566+
),
567+
);
568+
569+
// Next channel variant should have host + multiarch-std but have rls missing
570+
set_current_dist_date(config, "2019-09-14");
571+
expect_ok_ex(
572+
config,
573+
&["rustup", "update", "nightly", "--no-self-update"],
574+
&for_host!(
575+
r"
576+
nightly-{} unchanged - 1.37.0 (hash-nightly-1)
577+
578+
"
579+
),
580+
&format!(
581+
r"info: syncing channel updates for 'nightly-{0}'
582+
info: latest update on 2019-09-14, rust version 1.37.0 (hash-nightly-3)
583+
info: skipping nightly which is missing installed component 'rls'
584+
info: syncing channel updates for 'nightly-2019-09-13-{0}'
585+
info: latest update on 2019-09-13, rust version 1.37.0 (hash-nightly-2)
586+
info: skipping nightly which is missing installed component 'rust-std-{1}'
587+
info: syncing channel updates for 'nightly-2019-09-12-{0}'
588+
",
589+
clitools::this_host_triple(),
590+
clitools::MULTI_ARCH1,
591+
),
592+
);
593+
})
594+
}

tests/mock/clitools.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ pub enum Scenario {
6666
MissingNightly,
6767
/// Two dates, v2 manifests, host and MULTI_ARCH1 in first, host not in second
6868
HostGoesMissing,
69+
/// Three dates, v2 manifests, host and MULTI_ARCH1 in first, host only in second,
70+
/// host and MULTI_ARCH1 but no RLS in last
71+
MissingComponentMulti,
6972
}
7073

7174
pub static CROSS_ARCH1: &str = "x86_64-unknown-linux-musl";
@@ -684,6 +687,13 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
684687
Release::new("nightly", "1.3.0", "2019-12-09", "1"),
685688
Release::new("nightly", "1.3.0", "2019-12-10", "2").only_multi_arch(),
686689
],
690+
Scenario::MissingComponentMulti => vec![
691+
Release::new("nightly", "1.37.0", "2019-09-12", "1").multi_arch(),
692+
Release::new("nightly", "1.37.0", "2019-09-13", "2"),
693+
Release::new("nightly", "1.37.0", "2019-09-14", "3")
694+
.multi_arch()
695+
.with_rls(RlsStatus::Unavailable),
696+
],
687697
};
688698

689699
let vs = match s {
@@ -696,7 +706,8 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
696706
| Scenario::UnavailableRls
697707
| Scenario::MissingNightly
698708
| Scenario::HostGoesMissing
699-
| Scenario::MissingComponent => vec![ManifestVersion::V2],
709+
| Scenario::MissingComponent
710+
| Scenario::MissingComponentMulti => vec![ManifestVersion::V2],
700711
};
701712

702713
MockDistServer {

0 commit comments

Comments
 (0)