Skip to content

Enable v2 manifest support #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ install:
# Download nightly rust
- mkdir -p ~/rust
- echo -e "\033[33;1mDownloading Rust\033[0m"
- curl -sL http://static.rust-lang.org/dist/rust-nightly-$TARGET.tar.gz | tar --strip-components=1 -C ~/rust -xzf -
# FIXME: Pinned nightly for rust-lang/rust#32247
- curl -sL http://static.rust-lang.org/dist/2016-03-11/rust-nightly-$TARGET.tar.gz | tar --strip-components=1 -C ~/rust -xzf -
# For linux, install required packages
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
if [ "$BITS" == "32" ]; then
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ branches:
install:
- ps: |
# Install Rust
Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" -FileName "rust-nightly.exe"
# FIXME: Pinned nightly for rust-lang/rust#32247
Start-FileDownload "https://static.rust-lang.org/dist/2016-03-11/rust-nightly-${env:TARGET}.exe" -FileName "rust-nightly.exe"
.\rust-nightly.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null
$env:PATH="$env:PATH;C:\rust\bin"

Expand Down
40 changes: 15 additions & 25 deletions src/multirust-dist/src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,35 +272,25 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
remove_extensions: remove.to_owned(),
};

// Until the v2 dist manifests are actually deployed live they are
// not on by default. Putting this env var in Cfg an snaking it
// all the way down here didn't seem worth the effort since this
// should be short-lived.
let enable_experimental = ::std::env::var("MULTIRUST_ENABLE_EXPERIMENTAL").is_ok();
let already_using_v2 = try!(manifestation.read_config()).is_some();
let can_dl_v2_manifest = enable_experimental || already_using_v2;

// TODO: Add a notification about which manifest version is going to be used
download.notify_handler.call(Notification::DownloadingManifest);
if can_dl_v2_manifest {
match dl_v2_manifest(download, update_hash, toolchain) {
Ok(Some((m, hash))) => {
return match try!(manifestation.update(&m, changes, &download.temp_cfg,
download.notify_handler.clone())) {
UpdateStatus::Unchanged => Ok(None),
UpdateStatus::Changed => Ok(Some(hash)),
}
match dl_v2_manifest(download, update_hash, toolchain) {
Ok(Some((m, hash))) => {
return match try!(manifestation.update(&m, changes, &download.temp_cfg,
download.notify_handler.clone())) {
UpdateStatus::Unchanged => Ok(None),
UpdateStatus::Changed => Ok(Some(hash)),
}
Ok(None) => return Ok(None),
Err(Error::Utils(::multirust_utils::errors::Error::DownloadingFile {
error: ::multirust_utils::raw::DownloadError::Status(hyper::status::StatusCode::NotFound),
..
})) => {
// Proceed to try v1 as a fallback
download.notify_handler.call(Notification::DownloadingLegacyManifest);
}
Err(e) => return Err(e)
}
Ok(None) => return Ok(None),
Err(Error::Utils(::multirust_utils::errors::Error::DownloadingFile {
error: ::multirust_utils::raw::DownloadError::Status(hyper::status::StatusCode::NotFound),
..
})) => {
// Proceed to try v1 as a fallback
download.notify_handler.call(Notification::DownloadingLegacyManifest);
}
Err(e) => return Err(e)
}

// If the v2 manifest is not found then try v1
Expand Down
1 change: 0 additions & 1 deletion src/multirust-mock/src/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ pub fn cmd(config: &Config, name: &str, args: &[&str]) -> Command {
cmd.args(args);
cmd.env("MULTIRUST_HOME", config.homedir.path().to_string_lossy().to_string());
cmd.env("MULTIRUST_DIST_ROOT", format!("file://{}", config.distdir.path().join("dist").to_string_lossy()));
cmd.env("MULTIRUST_ENABLE_EXPERIMENTAL", "1");

cmd
}
Expand Down
15 changes: 1 addition & 14 deletions tests/cli-v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use multirust_mock::clitools::{self, Config, Scenario,
this_host_triple,
expect_ok, expect_stdout_ok, expect_err,
expect_stderr_ok, set_current_dist_date,
change_dir, run, cmd};
change_dir, run};

pub fn setup(f: &Fn(&Config)) {
clitools::setup(Scenario::SimpleV2, f);
Expand Down Expand Up @@ -504,19 +504,6 @@ fn upgrade_v2_to_v1() {
});
}

// v2 manifests only work with MULTIRUST_ENABLE_EXPERIMENTAL
#[test]
fn enable_experimental() {
setup(&|config| {
let mut cmd = cmd(config, "multirust", &["update", "nightly"]);
cmd.env_remove("MULTIRUST_ENABLE_EXPERIMENTAL");
let out = cmd.output().unwrap();
assert!(!out.status.success());
let stderr = String::from_utf8(out.stderr).unwrap();
assert!(stderr.contains("could not download file"));
});
}

#[test]
fn list_targets_no_toolchain() {
setup(&|config| {
Expand Down