diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index 99ef88a3250..68128b544d7 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -1291,46 +1291,48 @@ mod tests { #[test] async fn default_toolchain_is_stable() { - with_rustup_home(|home| async move { - let mut vars = HashMap::new(); - home.apply(&mut vars); - let tp = Box::new(currentprocess::TestProcess { - vars, - ..Default::default() - }); - currentprocess::with_tokio(tp.clone(), async { - // TODO: we could pass in a custom cfg to get notification - // callbacks rather than output to the tp sink. - let mut cfg = common::set_globals(false, false).unwrap(); + with_rustup_home(|home| { + Box::pin(async move { + let mut vars = HashMap::new(); + home.apply(&mut vars); + let tp = Box::new(currentprocess::TestProcess { + vars, + ..Default::default() + }); + currentprocess::with_tokio(tp.clone(), async { + // TODO: we could pass in a custom cfg to get notification + // callbacks rather than output to the tp sink. + let mut cfg = common::set_globals(false, false).unwrap(); + assert_eq!( + "stable" + .parse::() + .unwrap() + .resolve(&cfg.get_default_host_triple().unwrap()) + .unwrap(), + super::_install_selection( + &mut cfg, + None, // No toolchain specified + "default", // default profile + None, + true, + &[], + &[], + ) + .unwrap() // result + .unwrap() // option + ); + Ok::<(), anyhow::Error>(()) + }) + .unwrap(); assert_eq!( - "stable" - .parse::() - .unwrap() - .resolve(&cfg.get_default_host_triple().unwrap()) - .unwrap(), - super::_install_selection( - &mut cfg, - None, // No toolchain specified - "default", // default profile - None, - true, - &[], - &[], - ) - .unwrap() // result - .unwrap() // option - ); - Ok::<(), anyhow::Error>(()) - })?; - assert_eq!( - for_host!( - r"info: profile set to 'default' + for_host!( + r"info: profile set to 'default' info: default host triple is {0} " - ), - String::from_utf8(tp.get_stderr()).unwrap() - ); - Ok(()) + ), + String::from_utf8(tp.get_stderr()).unwrap() + ); + }) }) .await .unwrap(); diff --git a/src/cli/self_update/test.rs b/src/cli/self_update/test.rs index f6f610befbc..d8ee29e9907 100644 --- a/src/cli/self_update/test.rs +++ b/src/cli/self_update/test.rs @@ -1,6 +1,6 @@ //! Support for functional tests. -use std::sync::Mutex; +use std::{future::Future, pin::Pin, sync::Mutex}; #[cfg(not(unix))] use winreg::{ @@ -35,7 +35,7 @@ fn restore_path(p: Option) { } /// Support testing of code that mutates global path state -pub fn with_saved_path(f: &mut dyn FnMut()) { +pub async fn with_saved_path(f: &dyn Fn() -> Pin + Send>>) { // Lock protects concurrent mutation of registry static LOCK: Mutex<()> = Mutex::new(()); let _g = LOCK.lock(); @@ -45,7 +45,7 @@ pub fn with_saved_path(f: &mut dyn FnMut()) { let saved_path = get_path().expect("Error getting PATH: Better abort to avoid trashing it."); let _g = scopeguard::guard(saved_path, restore_path); - f(); + f().await; } #[cfg(unix)] diff --git a/src/cli/self_update/windows.rs b/src/cli/self_update/windows.rs index e68fc64624c..c7fcb75538e 100644 --- a/src/cli/self_update/windows.rs +++ b/src/cli/self_update/windows.rs @@ -747,118 +747,132 @@ mod tests { #[test] async fn windows_path_regkey_type() { // per issue #261, setting PATH should use REG_EXPAND_SZ. - let tp = Box::new(currentprocess::TestProcess::default()); + with_saved_path(&mut || { - currentprocess::with_tokio(tp.clone(), async { - let root = RegKey::predef(HKEY_CURRENT_USER); - let environment = root - .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) - .unwrap(); - environment.delete_value("PATH").unwrap(); - - { - // Can't compare the Results as Eq isn't derived; thanks error-chain. - #![allow(clippy::unit_cmp)] - assert_eq!((), super::_apply_new_path(Some(wide("foo"))).unwrap()); - } - let root = RegKey::predef(HKEY_CURRENT_USER); - let environment = root - .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) - .unwrap(); - let path = environment.get_raw_value("PATH").unwrap(); - assert_eq!(path.vtype, RegType::REG_EXPAND_SZ); - assert_eq!(super::to_winreg_bytes(wide("foo")), &path.bytes[..]); + let tp = Box::new(currentprocess::TestProcess::default()); + Box::pin(async move { + currentprocess::with_tokio(tp.clone(), async move { + let root = RegKey::predef(HKEY_CURRENT_USER); + let environment = root + .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) + .unwrap(); + environment.delete_value("PATH").unwrap(); + + { + // Can't compare the Results as Eq isn't derived; thanks error-chain. + #![allow(clippy::unit_cmp)] + assert_eq!((), super::_apply_new_path(Some(wide("foo"))).unwrap()); + } + let root = RegKey::predef(HKEY_CURRENT_USER); + let environment = root + .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) + .unwrap(); + let path = environment.get_raw_value("PATH").unwrap(); + assert_eq!(path.vtype, RegType::REG_EXPAND_SZ); + assert_eq!(super::to_winreg_bytes(wide("foo")), &path.bytes[..]); + }) }) - }); + }) + .await; } #[test] async fn windows_path_delete_key_when_empty() { - use std::io; - // during uninstall the PATH key may end up empty; if so we should - // delete it. - let tp = Box::new(currentprocess::TestProcess::default()); with_saved_path(&mut || { - currentprocess::with_tokio(tp.clone(), async { - let root = RegKey::predef(HKEY_CURRENT_USER); - let environment = root - .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) - .unwrap(); - environment - .set_raw_value( - "PATH", - &RegValue { - bytes: super::to_winreg_bytes(wide("foo")), - vtype: RegType::REG_EXPAND_SZ, - }, - ) - .unwrap(); - - { - // Can't compare the Results as Eq isn't derived; thanks error-chain. - #![allow(clippy::unit_cmp)] - assert_eq!((), super::_apply_new_path(Some(Vec::new())).unwrap()); - } - let reg_value = environment.get_raw_value("PATH"); - match reg_value { - Ok(_) => panic!("key not deleted"), - Err(ref e) if e.kind() == io::ErrorKind::NotFound => {} - Err(ref e) => panic!("error {e}"), - } + Box::pin(async move { + use std::io; + // during uninstall the PATH key may end up empty; if so we should + // delete it. + let tp = Box::new(currentprocess::TestProcess::default()); + + currentprocess::with_tokio(tp.clone(), async { + let root = RegKey::predef(HKEY_CURRENT_USER); + let environment = root + .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) + .unwrap(); + environment + .set_raw_value( + "PATH", + &RegValue { + bytes: super::to_winreg_bytes(wide("foo")), + vtype: RegType::REG_EXPAND_SZ, + }, + ) + .unwrap(); + + { + // Can't compare the Results as Eq isn't derived; thanks error-chain. + #![allow(clippy::unit_cmp)] + assert_eq!((), super::_apply_new_path(Some(Vec::new())).unwrap()); + } + let reg_value = environment.get_raw_value("PATH"); + match reg_value { + Ok(_) => panic!("key not deleted"), + Err(ref e) if e.kind() == io::ErrorKind::NotFound => {} + Err(ref e) => panic!("error {e}"), + } + }) }) - }); + }) + .await; } #[test] async fn windows_doesnt_mess_with_a_non_string_path() { - // This writes an error, so we want a sink for it. - let tp = Box::new(currentprocess::TestProcess { - vars: [("HOME".to_string(), "/unused".to_string())] - .iter() - .cloned() - .collect(), - ..Default::default() - }); with_saved_path(&mut || { - currentprocess::with_tokio(tp.clone(), async { - let root = RegKey::predef(HKEY_CURRENT_USER); - let environment = root - .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) - .unwrap(); - let reg_value = RegValue { - bytes: vec![0x12, 0x34], - vtype: RegType::REG_BINARY, - }; - environment.set_raw_value("PATH", ®_value).unwrap(); - // Ok(None) signals no change to the PATH setting layer + Box::pin(async move { + // This writes an error, so we want a sink for it. + let tp = Box::new(currentprocess::TestProcess { + vars: [("HOME".to_string(), "/unused".to_string())] + .iter() + .cloned() + .collect(), + ..Default::default() + }); + + currentprocess::with_tokio(tp.clone(), async { + let root = RegKey::predef(HKEY_CURRENT_USER); + let environment = root + .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) + .unwrap(); + let reg_value = RegValue { + bytes: vec![0x12, 0x34], + vtype: RegType::REG_BINARY, + }; + environment.set_raw_value("PATH", ®_value).unwrap(); + // Ok(None) signals no change to the PATH setting layer + assert_eq!( + None, + super::_with_path_cargo_home_bin(|_, _| panic!("called")).unwrap() + ); + }); assert_eq!( - None, - super::_with_path_cargo_home_bin(|_, _| panic!("called")).unwrap() + r"warning: the registry key HKEY_CURRENT_USER\Environment\PATH is not a string. Not modifying the PATH variable +", + String::from_utf8(tp.get_stderr()).unwrap() ); }) - }); - assert_eq!( - r"warning: the registry key HKEY_CURRENT_USER\Environment\PATH is not a string. Not modifying the PATH variable -", - String::from_utf8(tp.get_stderr()).unwrap() - ); + }).await; } #[test] async fn windows_treat_missing_path_as_empty() { // during install the PATH key may be missing; treat it as empty - let tp = Box::new(currentprocess::TestProcess::default()); with_saved_path(&mut || { - currentprocess::with_tokio(tp.clone(), async { - let root = RegKey::predef(HKEY_CURRENT_USER); - let environment = root - .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) - .unwrap(); - environment.delete_value("PATH").unwrap(); - - assert_eq!(Some(Vec::new()), super::get_windows_path_var().unwrap()); + Box::pin(async move { + let tp = Box::new(currentprocess::TestProcess::default()); + currentprocess::with_tokio(tp.clone(), async { + let root = RegKey::predef(HKEY_CURRENT_USER); + let environment = root + .open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE) + .unwrap(); + environment.delete_value("PATH").unwrap(); + + assert_eq!(Some(Vec::new()), super::get_windows_path_var().unwrap()); + }) }) - }); + }) + .await; } #[test] diff --git a/src/env_var.rs b/src/env_var.rs index ad11d9dba40..936a2de0f6f 100644 --- a/src/env_var.rs +++ b/src/env_var.rs @@ -49,54 +49,57 @@ mod tests { #[test] async fn prepend_unique_path() { - let mut vars = HashMap::new(); - vars.env( - "PATH", - env::join_paths(vec!["/home/a/.cargo/bin", "/home/b/.cargo/bin"].iter()).unwrap(), - ); - let tp = Box::new(currentprocess::TestProcess { - vars, - ..Default::default() - }); with_saved_path(&mut || { - currentprocess::with_tokio(tp.clone(), async { - let mut path_entries = vec![]; - let mut cmd = Command::new("test"); + Box::pin(async move { + let mut vars = HashMap::new(); + vars.env( + "PATH", + env::join_paths(vec!["/home/a/.cargo/bin", "/home/b/.cargo/bin"].iter()) + .unwrap(), + ); + let tp = Box::new(currentprocess::TestProcess { + vars, + ..Default::default() + }); + currentprocess::with_tokio(tp.clone(), async move { + let mut path_entries = vec![]; + let mut cmd = Command::new("test"); - let a = OsString::from("/home/a/.cargo/bin"); - let path_a = PathBuf::from(a); - path_entries.push(path_a); + let a = OsString::from("/home/a/.cargo/bin"); + let path_a = PathBuf::from(a); + path_entries.push(path_a); - let _a = OsString::from("/home/a/.cargo/bin"); - let _path_a = PathBuf::from(_a); - path_entries.push(_path_a); + let _a = OsString::from("/home/a/.cargo/bin"); + let _path_a = PathBuf::from(_a); + path_entries.push(_path_a); - let z = OsString::from("/home/z/.cargo/bin"); - let path_z = PathBuf::from(z); - path_entries.push(path_z); + let z = OsString::from("/home/z/.cargo/bin"); + let path_z = PathBuf::from(z); + path_entries.push(path_z); - prepend_path("PATH", path_entries, &mut cmd); - let envs: Vec<_> = cmd.get_envs().collect(); + prepend_path("PATH", path_entries, &mut cmd); + let envs: Vec<_> = cmd.get_envs().collect(); - assert_eq!( - envs, - &[( - OsStr::new("PATH"), - Some( - env::join_paths( - vec![ - "/home/z/.cargo/bin", - "/home/a/.cargo/bin", - "/home/b/.cargo/bin" - ] - .iter() + assert_eq!( + envs, + &[( + OsStr::new("PATH"), + Some( + env::join_paths( + vec![ + "/home/z/.cargo/bin", + "/home/a/.cargo/bin", + "/home/b/.cargo/bin" + ] + .iter() + ) + .unwrap() + .as_os_str() ) - .unwrap() - .as_os_str() - ) - ),] - ); - }); + ),] + ); + }); + }) }); } } diff --git a/src/test.rs b/src/test.rs index 1449b9b140d..c40a1b4da16 100644 --- a/src/test.rs +++ b/src/test.rs @@ -8,16 +8,14 @@ use std::env; use std::ffi::OsStr; use std::fmt; use std::fs; -#[cfg(test)] -use std::future::Future; use std::io; use std::path::{Path, PathBuf}; use std::process::Command; -#[cfg(test)] -use std::sync::Arc; #[cfg(test)] use anyhow::Result; +#[cfg(test)] +use futures::future::BoxFuture; pub use crate::cli::self_update::test::{get_path, with_saved_path}; use crate::currentprocess; @@ -219,14 +217,14 @@ impl fmt::Display for RustupHome { /// Create an isolated rustup home with no content, then call f with it, and /// delete it afterwards. #[cfg(test)] -pub(crate) async fn with_rustup_home(f: F) -> Result<()> +pub(crate) async fn with_rustup_home(f: F) -> Result<()> where - F: FnOnce(Arc) -> FR, - FR: Future>, + F: FnOnce(&mut RustupHome) -> BoxFuture<'_, ()>, { let test_dir = test_dir()?; - let rustup_home = RustupHome::new_in(test_dir)?.into(); - f(rustup_home).await + let mut rustup_home = RustupHome::new_in(test_dir)?; + f(&mut rustup_home).await; + Ok(()) } #[cfg(feature = "otel")] diff --git a/src/test/mock/clitools.rs b/src/test/mock/clitools.rs index e908c69302c..d6b129e1982 100644 --- a/src/test/mock/clitools.rs +++ b/src/test/mock/clitools.rs @@ -7,7 +7,6 @@ use std::{ ffi::OsStr, fmt::Debug, fs, - future::Future, io::{self, Write}, path::{Path, PathBuf}, process::Command, @@ -16,7 +15,7 @@ use std::{ }; use enum_map::{enum_map, Enum, EnumMap}; -use futures::future::join_all; +use futures::future::{join_all, BoxFuture}; use lazy_static::lazy_static; use once_cell::sync::Lazy; use url::Url; @@ -159,7 +158,7 @@ impl ConstState { } /// Get a dist server for a scenario - fn dist_server_for(&self, s: Scenario) -> io::Result { + async fn dist_server_for(&self, s: Scenario) -> io::Result { { // fast path: the dist already exists let lock = self.scenarios[s].read().unwrap(); @@ -175,7 +174,7 @@ impl ConstState { None => { let dist_path = self.const_dist_dir.path().join(format!("{s:?}")); - create_mock_dist_server(&dist_path, s); + create_mock_dist_server(&dist_path, s).await; *lock = Some(dist_path.clone()); Ok(dist_path) } @@ -307,16 +306,12 @@ pub async fn setup_test_state(test_dist_dir: tempfile::TempDir) -> (tempfile::Te /// Run this to create the test environment containing rustup, and /// a mock dist server. -pub async fn test(s: Scenario, f: F) -where - F: Fn(&mut Config) -> FR, - FR: Future, -{ +pub async fn test(s: Scenario, f: &dyn Fn(&mut Config) -> BoxFuture<'_, ()>) { // Things we might cache or what not // Mutable dist server - working toward elimination let test_dist_dir = crate::test::test_dist_dir().unwrap(); - create_mock_dist_server(test_dist_dir.path(), s); + create_mock_dist_server(test_dist_dir.path(), s).await; // Things that are just about the test itself let (_test_dir, mut config) = setup_test_state(test_dist_dir).await; @@ -346,40 +341,46 @@ async fn create_local_update_server(self_dist: &Path, exedir: &Path, version: &s root_url } -pub async fn self_update_setup(f: &dyn Fn(&mut Config, &Path), version: &str) { - test(Scenario::SimpleV2, |config| async { - // Create a mock self-update server - - let self_dist_tmp = tempfile::Builder::new() - .prefix("self_dist") - .tempdir_in(&config.test_root_dir) - .unwrap(); - let self_dist = self_dist_tmp.path(); - - let root_url = create_local_update_server(self_dist, &config.exedir, version).await; - config.rustup_update_root = Some(root_url); - - let trip = this_host_triple().await; - let dist_dir = self_dist.join(format!("archive/{version}/{trip}")); - let dist_exe = dist_dir.join(format!("rustup-init{EXE_SUFFIX}")); - let dist_tmp = dist_dir.join("rustup-init-tmp"); - - // Modify the exe so it hashes different - // 1) move out of the way the file - fs::rename(&dist_exe, &dist_tmp).unwrap(); - // 2) copy it - fs::copy(dist_tmp, &dist_exe).unwrap(); - // modify it - let mut dest_file = fs::OpenOptions::new() - .write(true) - .append(true) - .create(true) - .open(dist_exe) - .unwrap(); - writeln!(dest_file).unwrap(); - - f(config, self_dist); - }); +pub async fn self_update_setup<'a>( + f: &dyn Fn(&'a mut Config, &'a Path) -> BoxFuture<'a, ()>, + version: &str, +) { + test(Scenario::SimpleV2, &|config| { + Box::pin(async move { + // Create a mock self-update server + + let self_dist_tmp = tempfile::Builder::new() + .prefix("self_dist") + .tempdir_in(&config.test_root_dir) + .unwrap(); + let self_dist = self_dist_tmp.path(); + + // let root_url = create_local_update_server(self_dist, &config.exedir, version).await; + // config.rustup_update_root = Some(root_url); + + // let trip = this_host_triple().await; + // let dist_dir = self_dist.join(format!("archive/{version}/{trip}")); + // let dist_exe = dist_dir.join(format!("rustup-init{EXE_SUFFIX}")); + // let dist_tmp = dist_dir.join("rustup-init-tmp"); + + // // Modify the exe so it hashes different + // // 1) move out of the way the file + // fs::rename(&dist_exe, &dist_tmp).unwrap(); + // // 2) copy it + // fs::copy(dist_tmp, &dist_exe).unwrap(); + // // modify it + // let mut dest_file = fs::OpenOptions::new() + // .write(true) + // .append(true) + // .create(true) + // .open(dist_exe) + // .unwrap(); + // writeln!(dest_file).unwrap(); + + // f(config, self_dist); + }) + }) + .await; } pub async fn with_update_server(config: &mut Config, version: &str, f: &dyn Fn(&mut Config)) { @@ -445,8 +446,8 @@ impl Config { /// Move the dist server to the specified scenario and restore it /// afterwards. - pub fn with_scenario(&mut self, s: Scenario, f: &dyn Fn(&mut Config)) { - let dist_path = CONST_TEST_STATE.dist_server_for(s).unwrap(); + pub async fn with_scenario(&mut self, s: Scenario, f: &dyn Fn(&mut Config)) { + let dist_path = CONST_TEST_STATE.dist_server_for(s).await.unwrap(); self.const_dist_dir = Some(dist_path); f(self); self.const_dist_dir = None; diff --git a/tests/suite/cli_exact.rs b/tests/suite/cli_exact.rs index 854a8161fc9..08dbc5af886 100644 --- a/tests/suite/cli_exact.rs +++ b/tests/suite/cli_exact.rs @@ -8,25 +8,28 @@ use rustup::test::{ }; use rustup_macros::integration_test as test; +use futures::future::BoxFuture; + /// Start a test with Scenario::None -fn test(f: &dyn Fn(&mut Config)) { - clitools::test(Scenario::None, f); +async fn test(f: &dyn Fn(&mut Config) -> BoxFuture<'_, ()>) { + clitools::test(Scenario::None, f).await } #[test] async fn update_once() { test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { - config.expect_ok_ex( - &["rustup", "update", "nightly"], - for_host!( - r" + async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { + config.expect_ok_ex( + &["rustup", "update", "nightly"], + for_host!( + r" nightly-{0} installed - 1.3.0 (hash-nightly-2) " - ), - for_host!( - r"info: syncing channel updates for 'nightly-{0}' + ), + for_host!( + r"info: syncing channel updates for 'nightly-{0}' info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) info: downloading component 'cargo' info: downloading component 'rust-docs' @@ -38,18 +41,20 @@ info: installing component 'rust-std' info: installing component 'rustc' info: default toolchain set to 'nightly-{0}' " - ), - ); - }) + ), + ); + }) + } + .into() }); } #[test] async fn update_once_and_check_self_update() { let test_version = "2.0.0"; - test(&|config| { - with_update_server(config, test_version, &|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + with_update_server(config, test_version, &|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); config.expect_ok(&["rustup", "set", "auto-self-update", "check-only"]); let current_version = env!("CARGO_PKG_VERSION"); @@ -89,9 +94,9 @@ info: installing component 'rustc' async fn update_once_and_self_update() { let test_version = "2.0.0"; - test(&|config| { - with_update_server(config, test_version, &|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + with_update_server(config, test_version, &|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); config.expect_ok(&["rustup", "set", "auto-self-update", "enable"]); config.expect_ok_ex( @@ -125,8 +130,8 @@ info: downloading self-update #[test] async fn update_again() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_ok(&["rustup", "upgrade", "nightly"]); config.expect_ok_ex( @@ -161,8 +166,8 @@ async fn update_again() { #[test] async fn check_updates_none() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "stable", "beta", "nightly"]); config.expect_stdout_ok( &["rustup", "check"], @@ -179,11 +184,11 @@ nightly-{0} - Up to date : 1.3.0 (hash-nightly-2) #[test] async fn check_updates_some() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "stable", "beta", "nightly"]); }); - config.with_scenario(Scenario::SimpleV2, &|config| { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_stdout_ok( &["rustup", "check"], for_host!( @@ -201,9 +206,9 @@ nightly-{0} - Update available : 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2 async fn check_updates_self() { let test_version = "2.0.0"; - test(&|config| { - with_update_server(config, test_version, &|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + with_update_server(config, test_version, &|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let current_version = env!("CARGO_PKG_VERSION"); config.expect_stdout_ok( @@ -222,9 +227,9 @@ async fn check_updates_self() { async fn check_updates_self_no_change() { let current_version = env!("CARGO_PKG_VERSION"); - test(&|config| { - with_update_server(config, current_version, &|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + with_update_server(config, current_version, &|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_stdout_ok( &["rustup", "check"], &format!( @@ -240,7 +245,8 @@ async fn check_updates_self_no_change() { #[test] async fn check_updates_with_update() { test(&|config| { - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + async move { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "stable", "beta", "nightly"]); // XXX: This actually talks over the internet to the update server! config.expect_stdout_ok( @@ -252,8 +258,8 @@ nightly-{0} - Up to date : 1.2.0 (hash-nightly-1) " ), ); - }); - config.with_scenario(Scenario::SimpleV2, &|config | { + }.into()); + config.with_scenario(Scenario::SimpleV2, &|config | async move { config.expect_stdout_ok( &["rustup", "check"], for_host!( @@ -273,14 +279,15 @@ nightly-{0} - Update available : 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2 " ), ); - }) + }.into()) + }.into() }); } #[test] async fn default() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok_ex( &["rustup", "default", "nightly"], for_host!( @@ -310,8 +317,8 @@ info: default toolchain set to 'nightly-{0}' #[test] async fn override_again() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = config.current_dir(); config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_ok_ex( @@ -331,8 +338,8 @@ async fn override_again() { #[test] async fn remove_override() { for keyword in &["remove", "unset"] { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = config.current_dir(); config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_ok_ex( @@ -348,8 +355,8 @@ async fn remove_override() { #[test] async fn remove_override_none() { for keyword in &["remove", "unset"] { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = config.current_dir(); config.expect_ok_ex( &["rustup", "override", keyword], @@ -368,13 +375,13 @@ info: you may use `--path ` option to remove override toolchain for a spec #[test] async fn remove_override_with_path() { for keyword in &["remove", "unset"] { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let dir = tempfile::Builder::new() .prefix("rustup-test") .tempdir() .unwrap(); - config.change_dir(dir.path(), &|config| { + config.change_dir(dir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); }); config.expect_ok_ex( @@ -399,15 +406,15 @@ async fn remove_override_with_path() { #[test] async fn remove_override_with_path_deleted() { for keyword in &["remove", "unset"] { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let path = { let dir = tempfile::Builder::new() .prefix("rustup-test") .tempdir() .unwrap(); let path = std::fs::canonicalize(dir.path()).unwrap(); - config.change_dir(&path, &|config| { + config.change_dir(&path, &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); }); path @@ -435,15 +442,15 @@ async fn remove_override_with_path_deleted() { #[cfg_attr(target_os = "windows", ignore)] // FIXME #1103 async fn remove_override_nonexistent() { for keyword in &["remove", "unset"] { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let path = { let dir = tempfile::Builder::new() .prefix("rustup-test") .tempdir() .unwrap(); let path = std::fs::canonicalize(dir.path()).unwrap(); - config.change_dir(&path, &|config| { + config.change_dir(&path, &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); }); path @@ -466,8 +473,8 @@ async fn remove_override_nonexistent() { #[test] async fn list_overrides() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = std::fs::canonicalize(config.current_dir()).unwrap(); let mut cwd_formatted = format!("{}", cwd.display()); @@ -492,8 +499,8 @@ async fn list_overrides() { #[test] async fn list_overrides_with_nonexistent() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let trip = this_host_triple().await; let nonexistent_path = { @@ -501,7 +508,7 @@ async fn list_overrides_with_nonexistent() { .prefix("rustup-test") .tempdir() .unwrap(); - config.change_dir(dir.path(), &|config| { + config.change_dir(dir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); }); std::fs::canonicalize(dir.path()).unwrap() @@ -531,8 +538,8 @@ async fn list_overrides_with_nonexistent() { #[test] async fn update_no_manifest() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_err_ex( &["rustup", "update", "nightly-2016-01-01"], r"", @@ -549,7 +556,7 @@ error: no release found for 'nightly-2016-01-01' // Issue #111 #[test] async fn update_custom_toolchain() { - test(&|config| { + test(&|config| async move { // installable toolchains require 2 digits in the DD and MM fields, so this is // treated as a custom toolchain, which can't be used with update. config.expect_err( @@ -561,7 +568,7 @@ async fn update_custom_toolchain() { #[test] async fn default_custom_not_installed_toolchain() { - test(&|config| { + test(&|config| async move { // installable toolchains require 2 digits in the DD and MM fields, so this is // treated as a custom toolchain, which isn't installed. config.expect_err( @@ -573,7 +580,7 @@ async fn default_custom_not_installed_toolchain() { #[test] async fn default_none() { - test(&|config| { + test(&|config| async move { config.expect_stderr_ok( &["rustup", "default", "none"], "info: default toolchain unset", @@ -590,8 +597,8 @@ help: run 'rustup default stable' to download the latest stable release of Rust #[test] async fn list_targets() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let trip = this_host_triple().await; let mut sorted = vec![ format!("{} (installed)", &*trip), @@ -611,8 +618,8 @@ async fn list_targets() { #[test] async fn list_installed_targets() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let trip = this_host_triple().await; let mut sorted = vec![ trip, @@ -633,8 +640,8 @@ async fn list_installed_targets() { #[test] async fn cross_install_indicates_target() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); // TODO error 'nightly-x86_64-apple-darwin' is not installed config.expect_ok_ex( @@ -654,8 +661,8 @@ info: installing component 'rust-std' for '{0}' // issue #927 #[test] async fn undefined_linked_toolchain() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_err_ex( &["cargo", "+bogus", "test"], r"", @@ -667,8 +674,8 @@ async fn undefined_linked_toolchain() { #[test] async fn install_by_version_number() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2TwoVersions, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2TwoVersions, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "0.100.99"]); }) }) @@ -677,7 +684,7 @@ async fn install_by_version_number() { // issue #2191 #[test] async fn install_unreleased_component() { - clitools::test(Scenario::MissingComponentMulti, &|config| { + clitools::test(Scenario::MissingComponentMulti, &|config| async move { // Initial channel content is host + rls + multiarch-std set_current_dist_date(config, "2019-09-12"); config.expect_ok(&["rustup", "default", "nightly"]); diff --git a/tests/suite/cli_inst_interactive.rs b/tests/suite/cli_inst_interactive.rs index fe6add4a9f9..ebd9b665219 100644 --- a/tests/suite/cli_inst_interactive.rs +++ b/tests/suite/cli_inst_interactive.rs @@ -51,7 +51,7 @@ fn run_input_with_env( #[test] async fn update() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { with_saved_path(&mut || { run_input(config, &["rustup-init"], "\n\n"); let out = run_input(config, &["rustup-init"], "\n\n"); @@ -65,7 +65,7 @@ async fn update() { // test for the install case. #[test] async fn smoke_case_install_no_modify_path() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input(config, &["rustup-init", "--no-modify-path"], "\n\n"); assert!(out.ok); // During an interactive session, after "Press the Enter @@ -114,7 +114,7 @@ Rust is installed now. Great! #[test] async fn smoke_case_install_with_path_install() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { with_saved_path(&mut || { let out = run_input(config, &["rustup-init"], "\n\n"); assert!(out.ok); @@ -127,7 +127,7 @@ async fn smoke_case_install_with_path_install() { #[test] async fn blank_lines_around_stderr_log_output_update() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); let out = run_input( config, @@ -151,7 +151,7 @@ Rust is installed now. Great! #[test] async fn installer_shows_default_host_triple() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input(config, &["rustup-init", "--no-modify-path"], "2\n"); println!("-- stdout --\n {}", out.stdout); @@ -166,7 +166,7 @@ Default host triple? [{0}] #[test] async fn installer_shows_default_toolchain_as_stable() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input(config, &["rustup-init", "--no-modify-path"], "2\n\n"); println!("-- stdout --\n {}", out.stdout); @@ -181,7 +181,7 @@ Default toolchain? (stable/beta/nightly/none) [stable] #[test] async fn installer_shows_default_toolchain_when_set_in_args() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &[ @@ -204,7 +204,7 @@ Default toolchain? (stable/beta/nightly/none) [nightly] #[test] async fn installer_shows_default_profile() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input(config, &["rustup-init", "--no-modify-path"], "2\n\n\n"); println!("-- stdout --\n {}", out.stdout); @@ -219,7 +219,7 @@ Profile (which tools and data to install)? (minimal/default/complete) [default] #[test] async fn installer_shows_default_profile_when_set_in_args() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &["rustup-init", "--no-modify-path", "--profile=minimal"], @@ -238,7 +238,7 @@ Profile (which tools and data to install)? (minimal/default/complete) [minimal] #[test] async fn installer_shows_default_for_modify_path() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input(config, &["rustup-init"], "2\n\n\n\n"); println!("-- stdout --\n {}", out.stdout); @@ -253,7 +253,7 @@ Modify PATH variable? (Y/n) #[test] async fn installer_shows_default_for_modify_path_when_set_with_args() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input(config, &["rustup-init", "--no-modify-path"], "2\n\n\n\n"); println!("-- stdout --\n {}", out.stdout); @@ -268,7 +268,7 @@ Modify PATH variable? (y/N) #[test] async fn user_says_nope() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input(config, &["rustup-init", "--no-modify-path"], "n\n\n"); assert!(out.ok); assert!(!config.cargodir.join("bin").exists()); @@ -277,7 +277,7 @@ async fn user_says_nope() { #[test] async fn with_no_toolchain() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &[ @@ -295,7 +295,7 @@ async fn with_no_toolchain() { #[test] async fn with_non_default_toolchain_still_prompts() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &[ @@ -313,7 +313,7 @@ async fn with_non_default_toolchain_still_prompts() { #[test] async fn with_non_release_channel_non_default_toolchain() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &[ @@ -332,7 +332,7 @@ async fn with_non_release_channel_non_default_toolchain() { #[test] async fn set_nightly_toolchain() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &["rustup-init", "--no-modify-path"], @@ -346,7 +346,7 @@ async fn set_nightly_toolchain() { #[test] async fn set_no_modify_path() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &["rustup-init", "--no-modify-path"], @@ -362,7 +362,7 @@ async fn set_no_modify_path() { #[test] async fn set_nightly_toolchain_and_unset() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &["rustup-init", "--no-modify-path"], @@ -378,7 +378,7 @@ async fn set_nightly_toolchain_and_unset() { #[test] async fn user_says_nope_after_advanced_install() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = run_input( config, &["rustup-init", "--no-modify-path"], @@ -395,7 +395,7 @@ async fn install_with_components() { let mut args = vec!["rustup-init", "-y", "--no-modify-path"]; args.extend_from_slice(comp_args); - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_ok(&args); config.expect_stdout_ok(&["rustup", "component", "list"], "rust-src (installed)"); config.expect_stdout_ok( @@ -411,7 +411,7 @@ async fn install_with_components() { #[test] async fn install_forces_and_skips_rls() { - clitools::test(Scenario::UnavailableRls, &|config| { + clitools::test(Scenario::UnavailableRls, &|config| async move { set_current_dist_date(config, "2015-01-01"); let out = run_input( @@ -435,7 +435,7 @@ async fn install_forces_and_skips_rls() { #[test] async fn test_warn_if_complete_profile_is_used() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_stderr_ok( &[ "rustup-init", @@ -451,7 +451,7 @@ async fn test_warn_if_complete_profile_is_used() { #[test] async fn test_prompt_fail_if_rustup_sh_already_installed_reply_nothing() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.create_rustup_sh_metadata(); let out = run_input(config, &["rustup-init", "--no-modify-path"], "\n"); assert!(!out.ok); @@ -467,7 +467,7 @@ async fn test_prompt_fail_if_rustup_sh_already_installed_reply_nothing() { #[test] async fn test_prompt_fail_if_rustup_sh_already_installed_reply_no() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.create_rustup_sh_metadata(); let out = run_input(config, &["rustup-init", "--no-modify-path"], "no\n"); assert!(!out.ok); @@ -483,7 +483,7 @@ async fn test_prompt_fail_if_rustup_sh_already_installed_reply_no() { #[test] async fn test_prompt_succeed_if_rustup_sh_already_installed_reply_yes() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.create_rustup_sh_metadata(); let out = run_input(config, &["rustup-init", "--no-modify-path"], "yes\n\n\n"); assert!(out @@ -502,7 +502,7 @@ async fn test_prompt_succeed_if_rustup_sh_already_installed_reply_yes() { #[test] async fn installing_when_already_installed_updates_toolchain() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); let out = run_input(config, &["rustup-init", "--no-modify-path"], "\n\n"); println!("stdout:\n{}\n...\n", out.stdout); @@ -523,7 +523,7 @@ async fn install_stops_if_rustc_exists() { raw::append_file(&fake_exe, "").unwrap(); let temp_dir_path = temp_dir.path().to_str().unwrap(); - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = config.run( "rustup-init", ["--no-modify-path"], @@ -553,7 +553,7 @@ async fn install_stops_if_cargo_exists() { raw::append_file(&fake_exe, "").unwrap(); let temp_dir_path = temp_dir.path().to_str().unwrap(); - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = config.run( "rustup-init", ["--no-modify-path"], @@ -583,7 +583,7 @@ async fn with_no_prompt_install_succeeds_if_rustc_exists() { raw::append_file(&fake_exe, "").unwrap(); let temp_dir_path = temp_dir.path().to_str().unwrap(); - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let out = config.run( "rustup-init", ["-y", "--no-modify-path"], @@ -599,7 +599,7 @@ async fn with_no_prompt_install_succeeds_if_rustc_exists() { // Issue 2547 #[test] async fn install_non_installable_toolchain() { - clitools::test(Scenario::Unavailable, &|config| { + clitools::test(Scenario::Unavailable, &|config| async move { config.expect_err( &[ "rustup-init", diff --git a/tests/suite/cli_misc.rs b/tests/suite/cli_misc.rs index 22f2f9741b7..f6d146814d8 100644 --- a/tests/suite/cli_misc.rs +++ b/tests/suite/cli_misc.rs @@ -4,6 +4,8 @@ use std::str; use std::{env::consts::EXE_SUFFIX, path::Path}; +use futures::future::BoxFuture; + use rustup::for_host; use rustup::test::{ mock::clitools::{self, set_current_dist_date, Config, Scenario}, @@ -12,20 +14,21 @@ use rustup::test::{ use rustup::utils::utils; use rustup_macros::integration_test as test; -pub fn setup(f: &dyn Fn(&mut Config)) { - clitools::test(Scenario::SimpleV2, f); +pub async fn setup(f: &dyn Fn(&mut Config) -> BoxFuture<'_, ()>) { + clitools::test(Scenario::SimpleV2, f).await; } #[test] async fn smoke_test() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "--version"]); - }); + }) + .await; } #[test] async fn version_mentions_rustc_version_confusion() { - setup(&|config| { + setup(&|config| async move { let out = config.run("rustup", vec!["--version"], &[]); assert!(out.ok); assert!(out @@ -42,7 +45,7 @@ async fn version_mentions_rustc_version_confusion() { #[test] async fn no_colors_in_piped_error_output() { - setup(&|config| { + setup(&|config| async move { let args: Vec<&str> = vec![]; let out = config.run("rustc", args, &[]); assert!(!out.ok); @@ -52,7 +55,7 @@ async fn no_colors_in_piped_error_output() { #[test] async fn rustc_with_bad_rustup_toolchain_env_var() { - setup(&|config| { + setup(&|config| async move { let args: Vec<&str> = vec![]; let out = config.run("rustc", args, &[("RUSTUP_TOOLCHAIN", "bogus")]); assert!(!out.ok); @@ -62,7 +65,7 @@ async fn rustc_with_bad_rustup_toolchain_env_var() { #[test] async fn custom_invalid_names() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustup", "toolchain", "link", "nightly", "foo"], "invalid custom toolchain name 'nightly'", @@ -80,7 +83,7 @@ async fn custom_invalid_names() { #[test] async fn custom_invalid_names_with_archive_dates() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustup", "toolchain", "link", "nightly-2015-01-01", "foo"], "invalid custom toolchain name 'nightly-2015-01-01'", @@ -99,7 +102,7 @@ async fn custom_invalid_names_with_archive_dates() { // Regression test for newline placement #[test] async fn update_all_no_update_whitespace() { - setup(&|config| { + setup(&|config| async move { config.expect_stdout_ok( &["rustup", "update", "nightly"], for_host!( @@ -115,7 +118,7 @@ async fn update_all_no_update_whitespace() { // Issue #145 #[test] async fn update_works_without_term() { - setup(&|config| { + setup(&|config| async move { let mut cmd = clitools::cmd(config, "rustup", ["update", "nightly"]); clitools::env(config, &mut cmd); cmd.env_remove("TERM"); @@ -128,7 +131,7 @@ async fn update_works_without_term() { // Issue #1738 #[test] async fn show_works_with_dumb_term() { - setup(&|config| { + setup(&|config| async move { let mut cmd = clitools::cmd(config, "rustup", ["show"]); clitools::env(config, &mut cmd); cmd.env("TERM", "dumb"); @@ -140,7 +143,7 @@ async fn show_works_with_dumb_term() { // Exit with error and help output when called without subcommand. #[test] async fn subcommand_required_for_target() { - setup(&|config| { + setup(&|config| async move { let mut cmd = clitools::cmd(config, "rustup", ["target"]); clitools::env(config, &mut cmd); let out = cmd.output().unwrap(); @@ -154,7 +157,7 @@ async fn subcommand_required_for_target() { // Exit with error and help output when called without subcommand. #[test] async fn subcommand_required_for_toolchain() { - setup(&|config| { + setup(&|config| async move { let mut cmd = clitools::cmd(config, "rustup", ["toolchain"]); clitools::env(config, &mut cmd); let out = cmd.output().unwrap(); @@ -168,7 +171,7 @@ async fn subcommand_required_for_toolchain() { // Exit with error and help output when called without subcommand. #[test] async fn subcommand_required_for_override() { - setup(&|config| { + setup(&|config| async move { let mut cmd = clitools::cmd(config, "rustup", ["override"]); clitools::env(config, &mut cmd); let out = cmd.output().unwrap(); @@ -182,7 +185,7 @@ async fn subcommand_required_for_override() { // Exit with error and help output when called without subcommand. #[test] async fn subcommand_required_for_self() { - setup(&|config| { + setup(&|config| async move { let mut cmd = clitools::cmd(config, "rustup", ["self"]); clitools::env(config, &mut cmd); let out = cmd.output().unwrap(); @@ -199,7 +202,7 @@ async fn multi_host_smoke_test() { // to be sure. assert_ne!(this_host_triple(), clitools::MULTI_ARCH1); - clitools::test(Scenario::MultiHost, &|config| { + clitools::test(Scenario::MultiHost, &|config| async move { let toolchain = format!("nightly-{}", clitools::MULTI_ARCH1); config.expect_ok(&["rustup", "default", &toolchain]); config.expect_stdout_ok(&["rustc", "--version"], "xxxx-nightly-2"); // cross-host mocks have their own versions @@ -208,7 +211,7 @@ async fn multi_host_smoke_test() { #[test] async fn custom_toolchain_cargo_fallback_proxy() { - setup(&|config| { + setup(&|config| async move { let path = config.customdir.join("custom-1"); config.expect_ok(&[ @@ -233,7 +236,7 @@ async fn custom_toolchain_cargo_fallback_proxy() { #[test] async fn custom_toolchain_cargo_fallback_run() { - setup(&|config| { + setup(&|config| async move { let path = config.customdir.join("custom-1"); config.expect_ok(&[ @@ -267,7 +270,7 @@ async fn custom_toolchain_cargo_fallback_run() { #[test] async fn rustup_run_searches_path() { - setup(&|config| { + setup(&|config| async move { #[cfg(windows)] let hello_cmd = &["rustup", "run", "nightly", "cmd", "/C", "echo hello"]; #[cfg(not(windows))] @@ -280,7 +283,7 @@ async fn rustup_run_searches_path() { #[test] async fn rustup_doesnt_prepend_path_unnecessarily() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); let expect_stderr_ok_env_first_then = @@ -366,7 +369,7 @@ async fn rustup_doesnt_prepend_path_unnecessarily() { #[test] async fn rustup_failed_path_search() { - setup(&|config| { + setup(&|config| async move { use std::env::consts::EXE_SUFFIX; let rustup_path = config.exedir.join(format!("rustup{EXE_SUFFIX}")); @@ -399,7 +402,7 @@ async fn rustup_failed_path_search() { #[test] async fn rustup_failed_path_search_toolchain() { - setup(&|config| { + setup(&|config| async move { use std::env::consts::EXE_SUFFIX; let rustup_path = config.exedir.join(format!("rustup{EXE_SUFFIX}")); @@ -437,7 +440,7 @@ async fn rustup_failed_path_search_toolchain() { #[test] async fn rustup_run_not_installed() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "install", "stable"]); config.expect_err( &["rustup", "run", "nightly", "rustc", "--version"], @@ -448,7 +451,7 @@ async fn rustup_run_not_installed() { #[test] async fn rustup_run_install() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "install", "stable"]); config.expect_stderr_ok( &[ @@ -466,7 +469,7 @@ async fn rustup_run_install() { #[test] async fn toolchains_are_resolved_early() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); let full_toolchain = format!("nightly-{}", this_host_triple()); @@ -479,7 +482,7 @@ async fn toolchains_are_resolved_early() { #[test] async fn no_panic_on_default_toolchain_missing() { - setup(&|config| { + setup(&|config| async move { config.expect_err(&["rustup", "default"], "no default toolchain configured"); }); } @@ -487,7 +490,7 @@ async fn no_panic_on_default_toolchain_missing() { // #190 #[test] async fn proxies_pass_empty_args() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "run", "nightly", "rustc", "--empty-arg-test", ""]); }); @@ -495,7 +498,7 @@ async fn proxies_pass_empty_args() { #[test] async fn rls_exists_in_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "component", "add", "rls"]); @@ -506,7 +509,7 @@ async fn rls_exists_in_toolchain() { #[test] async fn run_rls_when_not_available_in_toolchain() { - clitools::test(Scenario::UnavailableRls, &|config| { + clitools::test(Scenario::UnavailableRls, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( @@ -528,7 +531,7 @@ async fn run_rls_when_not_available_in_toolchain() { #[test] async fn run_rls_when_not_installed() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_err( &["rls", "--version"], @@ -543,7 +546,7 @@ async fn run_rls_when_not_installed() { #[test] async fn run_rust_lldb_when_not_in_toolchain() { - clitools::test(Scenario::UnavailableRls, &|config| { + clitools::test(Scenario::UnavailableRls, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( @@ -559,7 +562,7 @@ async fn run_rust_lldb_when_not_in_toolchain() { #[test] async fn rename_rls_before() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "component", "add", "rls"]); @@ -574,7 +577,7 @@ async fn rename_rls_before() { #[test] async fn rename_rls_after() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -589,7 +592,7 @@ async fn rename_rls_after() { #[test] async fn rename_rls_add_old_name() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -604,7 +607,7 @@ async fn rename_rls_add_old_name() { #[test] async fn rename_rls_list() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -620,7 +623,7 @@ async fn rename_rls_list() { #[test] async fn rename_rls_preview_list() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -636,7 +639,7 @@ async fn rename_rls_preview_list() { #[test] async fn rename_rls_remove() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -680,7 +683,7 @@ async fn toolchain_broken_symlink() { fs::symlink_dir(src, dst).unwrap(); } - clitools::test(Scenario::None, &|config| { + clitools::test(Scenario::None, &|config| async move { // We artificially create a broken symlink toolchain -- but this can also happen "legitimately" // by having a proper toolchain there, using "toolchain link", and later removing the directory. fs::create_dir(config.rustupdir.join("toolchains")).unwrap(); @@ -708,7 +711,7 @@ info: toolchain 'test' uninstalled // issue #1297 #[test] async fn update_unavailable_rustc() { - clitools::test(Scenario::Unavailable, &|config| { + clitools::test(Scenario::Unavailable, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -725,7 +728,7 @@ async fn update_unavailable_rustc() { // issue 2562 #[test] async fn install_unavailable_platform() { - clitools::test(Scenario::Unavailable, &|config| { + clitools::test(Scenario::Unavailable, &|config| async move { set_current_dist_date(config, "2015-01-02"); // explicit attempt to install should fail config.expect_err( @@ -739,7 +742,7 @@ async fn install_unavailable_platform() { #[test] async fn update_nightly_even_with_incompat() { - clitools::test(Scenario::MissingComponent, &|config| { + clitools::test(Scenario::MissingComponent, &|config| async move { set_current_dist_date(config, "2019-09-12"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -760,7 +763,7 @@ async fn update_nightly_even_with_incompat() { #[test] async fn nightly_backtrack_skips_missing() { - clitools::test(Scenario::MissingNightly, &|config| { + clitools::test(Scenario::MissingNightly, &|config| async move { set_current_dist_date(config, "2019-09-16"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -779,14 +782,14 @@ async fn nightly_backtrack_skips_missing() { #[test] async fn completion_rustup() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "completions", "bash", "rustup"]); }); } #[test] async fn completion_cargo() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "completions", "bash", "cargo"]); }); } @@ -794,16 +797,19 @@ async fn completion_cargo() { #[test] async fn completion_default() { setup(&|config| { - config.expect_ok_eq( - &["rustup", "completions", "bash"], - &["rustup", "completions", "bash", "rustup"], - ); + async move { + config.expect_ok_eq( + &["rustup", "completions", "bash"], + &["rustup", "completions", "bash", "rustup"], + ); + } + .into() }); } #[test] async fn completion_bad_shell() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustup", "completions", "fake"], r#"error: "fake" isn't a valid value for ''"#, @@ -817,7 +823,7 @@ async fn completion_bad_shell() { #[test] async fn completion_bad_tool() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustup", "completions", "bash", "fake"], r#"error: "fake" isn't a valid value for ''"#, @@ -827,7 +833,7 @@ async fn completion_bad_tool() { #[test] async fn completion_cargo_unsupported_shell() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustup", "completions", "fish", "cargo"], "error: cargo does not currently support completions for ", @@ -837,7 +843,7 @@ async fn completion_cargo_unsupported_shell() { #[test] async fn add_remove_component() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_component_executable("rustc"); config.expect_ok(&["rustup", "component", "remove", "rustc"]); @@ -849,7 +855,7 @@ async fn add_remove_component() { #[test] async fn which() { - setup(&|config| { + setup(&|config| async move { let path_1 = config.customdir.join("custom-1"); let path_1 = path_1.to_string_lossy(); config.expect_ok(&["rustup", "toolchain", "link", "custom-1", &path_1]); @@ -882,7 +888,7 @@ async fn which() { #[test] async fn which_asking_uninstalled_toolchain() { - setup(&|config| { + setup(&|config| async move { let path_1 = config.customdir.join("custom-1"); let path_1 = path_1.to_string_lossy(); config.expect_ok(&["rustup", "toolchain", "link", "custom-1", &path_1]); @@ -906,7 +912,7 @@ async fn which_asking_uninstalled_toolchain() { #[test] async fn override_by_toolchain_on_the_command_line() { - setup(&|config| { + setup(&|config| async move { #[cfg(windows)] config.expect_stdout_ok( &["rustup", "+stable", "which", "rustc"], @@ -954,7 +960,7 @@ async fn override_by_toolchain_on_the_command_line() { #[test] async fn toolchain_link_then_list_verbose() { - setup(&|config| { + setup(&|config| async move { let path_1 = config.customdir.join("custom-1"); let path_1 = path_1.to_string_lossy(); config.expect_ok(&["rustup", "toolchain", "link", "custom-1", &path_1]); @@ -967,7 +973,7 @@ async fn toolchain_link_then_list_verbose() { #[test] async fn deprecated_interfaces() { - setup(&|config| { + setup(&|config| async move { // In verbose mode we want the deprecated interfaces to complain config.expect_ok_contains( &["rustup", "--verbose", "install", "nightly"], diff --git a/tests/suite/cli_paths.rs b/tests/suite/cli_paths.rs index b55b71224e3..ccaf180817c 100644 --- a/tests/suite/cli_paths.rs +++ b/tests/suite/cli_paths.rs @@ -41,7 +41,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_creates_necessary_scripts() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { // Override the test harness so that cargo home looks like // $HOME/.cargo by removing CARGO_HOME from the environment, // otherwise the literal path will be written to the file. @@ -73,7 +73,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_updates_bash_rcs() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let rcs: Vec = [".bashrc", ".bash_profile", ".bash_login", ".profile"] .iter() .map(|rc| config.homedir.join(rc)) @@ -94,7 +94,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_does_not_create_bash_rcs() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let rcs: Vec = [".bashrc", ".bash_profile", ".bash_login"] .iter() .map(|rc| config.homedir.join(rc)) @@ -112,7 +112,7 @@ export PATH="$HOME/apple/bin" // This test should NOT be run as root! #[test] fn install_errors_when_rc_cannot_be_updated() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let rc = config.homedir.join(".profile"); fs::File::create(&rc).unwrap(); let mut perms = fs::metadata(&rc).unwrap().permissions(); @@ -125,7 +125,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_with_zdotdir() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let zdotdir = tempfile::Builder::new() .prefix("zdotdir") .tempdir() @@ -146,7 +146,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_adds_path_to_rc_just_once() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let profile = config.homedir.join(".profile"); raw::write_file(&profile, FAKE_RC).unwrap(); config.expect_ok(&INIT_NONE); @@ -160,7 +160,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_adds_path_to_rc_handling_no_newline() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let profile = config.homedir.join(".profile"); let fake_rc_modified = FAKE_RC.strip_suffix('\n').expect("Should end in a newline"); raw::write_file(&profile, fake_rc_modified).unwrap(); @@ -177,7 +177,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_adds_path_to_multiple_rc_files() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { // Two RC files that are both from the same shell let bash_profile = config.homedir.join(".bash_profile"); let bashrc = config.homedir.join(".bashrc"); @@ -201,7 +201,7 @@ export PATH="$HOME/apple/bin" #[test] fn uninstall_removes_source_from_rcs() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let rcs: Vec = [ ".bashrc", ".bash_profile", @@ -229,7 +229,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_adds_sources_while_removing_legacy_paths() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let zdotdir = tempfile::Builder::new() .prefix("zdotdir") .tempdir() @@ -267,7 +267,7 @@ export PATH="$HOME/apple/bin" #[test] fn uninstall_cleans_up_legacy_paths() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { // Install first, then overwrite. config.expect_ok(&INIT_NONE); @@ -309,7 +309,7 @@ export PATH="$HOME/apple/bin" // not the full path. #[test] fn when_cargo_home_is_the_default_write_path_specially() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { // Override the test harness so that cargo home looks like // $HOME/.cargo by removing CARGO_HOME from the environment, // otherwise the literal path will be written to the file. @@ -335,7 +335,7 @@ export PATH="$HOME/apple/bin" #[test] fn install_doesnt_modify_path_if_passed_no_modify_path() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let profile = config.homedir.join(".profile"); config.expect_ok(&[ "rustup-init", @@ -360,7 +360,7 @@ mod windows { #[test] /// Smoke test for end-to-end code connectivity of the installer path mgmt on windows. async fn install_uninstall_affect_path() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { with_saved_path(&mut || { let path = format!("{:?}", config.cargodir.join("bin").to_string_lossy()); @@ -390,7 +390,7 @@ mod windows { use winreg::enums::{RegType, HKEY_CURRENT_USER, KEY_READ, KEY_WRITE}; use winreg::{RegKey, RegValue}; - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { with_saved_path(&mut || { // Set up a non unicode PATH let reg_value = RegValue { diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index 61e0ce330ae..b54fbad1097 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -20,17 +20,17 @@ macro_rules! for_host_and_home { }; } -fn test(f: &dyn Fn(&mut Config)) { +async fn test(f: &dyn Fn(&mut Config)) { clitools::test(Scenario::None, f); } #[test] async fn rustup_stable() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "stable"]); }); - config.with_scenario(Scenario::SimpleV2, &|config| { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok_ex( &["rustup", "update"], for_host!( @@ -64,11 +64,11 @@ info: cleaning up downloads & tmp directories #[test] async fn rustup_stable_quiet() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "--quiet", "update", "stable"]); }); - config.with_scenario(Scenario::SimpleV2, &|config| { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok_ex( &["rustup", "--quiet", "update"], for_host!( @@ -102,8 +102,8 @@ info: cleaning up downloads & tmp directories #[test] async fn rustup_stable_no_change() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "update", "stable"]); config.expect_ok_ex( &["rustup", "update"], @@ -125,11 +125,11 @@ info: cleaning up downloads & tmp directories #[test] async fn rustup_all_channels() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "stable", "beta", "nightly"]); }); - config.with_scenario(Scenario::SimpleV2, &|config| { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok_ex( &["rustup", "update"], for_host!( @@ -193,11 +193,11 @@ info: cleaning up downloads & tmp directories #[test] async fn rustup_some_channels_up_to_date() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "stable", "beta", "nightly"]); }); - config.with_scenario(Scenario::SimpleV2, &|config| { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "update", "beta"]); config.expect_ok_ex( &["rustup", "update"], @@ -249,8 +249,8 @@ info: cleaning up downloads & tmp directories #[test] async fn rustup_no_channels() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok_ex( &["rustup", "update"], r"", @@ -264,8 +264,8 @@ info: cleaning up downloads & tmp directories #[test] async fn default() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok_ex( &["rustup", "default", "nightly"], for_host!( @@ -295,8 +295,8 @@ info: default toolchain set to 'nightly-{0}' #[test] async fn default_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "nightly"]); config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "override", "set", "nightly"]); @@ -314,8 +314,8 @@ info: note that the toolchain 'nightly-{0}' is currently in use (directory overr #[test] async fn rustup_zstd() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_stderr_ok( &["rustup", "--verbose", "toolchain", "add", "nightly"], for_host!(r"dist/2015-01-01/rust-std-nightly-{0}.tar.zst"), @@ -326,8 +326,8 @@ async fn rustup_zstd() { #[test] async fn add_target() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let path = format!( "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", &this_host_triple(), @@ -342,8 +342,8 @@ async fn add_target() { #[test] async fn remove_target() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let path = format!( "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", &this_host_triple(), @@ -360,56 +360,59 @@ async fn remove_target() { #[test] async fn add_remove_multiple_targets() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { - config.expect_ok(&["rustup", "default", "nightly"]); - config.expect_ok(&[ - "rustup", - "target", - "add", - clitools::CROSS_ARCH1, - clitools::CROSS_ARCH2, - ]); - let path = format!( - "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", - &this_host_triple(), - clitools::CROSS_ARCH1 - ); - assert!(config.rustupdir.has(path)); - let path = format!( - "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", - &this_host_triple(), - clitools::CROSS_ARCH2 - ); - assert!(config.rustupdir.has(path)); + test(&|config| async move { + async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { + config.expect_ok(&["rustup", "default", "nightly"]); + config.expect_ok(&[ + "rustup", + "target", + "add", + clitools::CROSS_ARCH1, + clitools::CROSS_ARCH2, + ]); + let path = format!( + "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", + &this_host_triple(), + clitools::CROSS_ARCH1 + ); + assert!(config.rustupdir.has(path)); + let path = format!( + "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", + &this_host_triple(), + clitools::CROSS_ARCH2 + ); + assert!(config.rustupdir.has(path)); - config.expect_ok(&[ - "rustup", - "target", - "remove", - clitools::CROSS_ARCH1, - clitools::CROSS_ARCH2, - ]); - let path = format!( - "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", - &this_host_triple(), - clitools::CROSS_ARCH1 - ); - assert!(!config.rustupdir.has(path)); - let path = format!( - "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", - &this_host_triple(), - clitools::CROSS_ARCH2 - ); - assert!(!config.rustupdir.has(path)); - }) + config.expect_ok(&[ + "rustup", + "target", + "remove", + clitools::CROSS_ARCH1, + clitools::CROSS_ARCH2, + ]); + let path = format!( + "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", + &this_host_triple(), + clitools::CROSS_ARCH1 + ); + assert!(!config.rustupdir.has(path)); + let path = format!( + "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", + &this_host_triple(), + clitools::CROSS_ARCH2 + ); + assert!(!config.rustupdir.has(path)); + }) + } + .into() }); } #[test] async fn list_targets() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustup", "target", "list"], clitools::CROSS_ARCH1); }) @@ -418,8 +421,8 @@ async fn list_targets() { #[test] async fn list_installed_targets() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let trip = this_host_triple().await; config.expect_ok(&["rustup", "default", "nightly"]); @@ -430,8 +433,8 @@ async fn list_installed_targets() { #[test] async fn add_target_explicit() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let path = format!( "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", &this_host_triple(), @@ -453,8 +456,8 @@ async fn add_target_explicit() { #[test] async fn remove_target_explicit() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let path = format!( "toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib", &this_host_triple(), @@ -485,8 +488,8 @@ async fn remove_target_explicit() { #[test] async fn list_targets_explicit() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "nightly"]); config.expect_stdout_ok( &["rustup", "target", "list", "--toolchain", "nightly"], @@ -498,8 +501,8 @@ async fn list_targets_explicit() { #[test] async fn link() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let path = config.customdir.join("custom-1"); let path = path.to_string_lossy(); config.expect_ok(&["rustup", "toolchain", "link", "custom", &path]); @@ -518,8 +521,8 @@ async fn link() { // That way the proxy can pick the correct toolchain. #[test] async fn fallback_cargo_calls_correct_rustc() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { // Hm, this is the _only_ test that assumes that toolchain proxies // exist in CARGO_HOME. Adding that proxy here. let rustup_path = config.exedir.join(format!("rustup{EXE_SUFFIX}")); @@ -568,8 +571,8 @@ async fn fallback_cargo_calls_correct_rustc() { // and the first argument would be `+nightly` which would be an error. #[test] async fn recursive_cargo() { - test(&|config| { - config.with_scenario(Scenario::ArchivesV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::ArchivesV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); // We need an intermediary to run cargo itself. @@ -607,7 +610,7 @@ async fn recursive_cargo() { #[test] async fn show_home() { - test(&|config| { + test(&|config| async move { config.expect_ok_ex( &["rustup", "show", "home"], &format!( @@ -622,7 +625,7 @@ async fn show_home() { #[test] async fn show_toolchain_none() { - test(&|config| { + test(&|config| async move { config.expect_ok_ex( &["rustup", "show"], for_host_and_home!( @@ -640,8 +643,8 @@ no active toolchain #[test] async fn show_toolchain_default() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok_ex( &["rustup", "show"], @@ -662,8 +665,8 @@ nightly-{0} (default) #[test] async fn show_multiple_toolchains() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "update", "stable"]); config.expect_ok_ex( @@ -695,8 +698,8 @@ nightly-{0} (default) #[test] async fn show_multiple_targets() { - test(&|config| { - config.with_scenario(Scenario::MultiHost, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::MultiHost, &|config| async move { config.expect_ok(&[ "rustup", "default", @@ -739,8 +742,8 @@ async fn show_multiple_toolchains_and_targets() { return; } - test(&|config| { - config.with_scenario(Scenario::MultiHost, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::MultiHost, &|config| async move { config.expect_ok(&[ "rustup", "default", @@ -790,8 +793,8 @@ nightly-{0} (default) #[test] async fn list_default_toolchain() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok_ex( &["rustup", "toolchain", "list"], @@ -807,8 +810,8 @@ async fn list_default_toolchain() { #[test] async fn list_override_toolchain() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "override", "set", "nightly"]); config.expect_ok_ex( &["rustup", "toolchain", "list"], @@ -824,8 +827,8 @@ async fn list_override_toolchain() { #[test] async fn list_default_and_override_toolchain() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "override", "set", "nightly"]); config.expect_ok_ex( @@ -842,8 +845,8 @@ async fn list_default_and_override_toolchain() { #[test] async fn heal_damaged_toolchain() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_not_stderr_ok( &["rustup", "show", "active-toolchain"], @@ -878,8 +881,8 @@ async fn heal_damaged_toolchain() { #[test] #[ignore = "FIXME: Windows shows UNC paths"] fn show_toolchain_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = config.current_dir(); config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_ok_ex( @@ -904,8 +907,8 @@ nightly-{0} (directory override for '{2}') #[test] #[ignore = "FIXME: Windows shows UNC paths"] fn show_toolchain_toolchain_file_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -946,8 +949,8 @@ nightly-{0} (overridden by '{2}') #[test] #[ignore = "FIXME: Windows shows UNC paths"] fn show_toolchain_version_nested_file_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "toolchain", "add", "stable", "beta", "nightly"]); config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -960,7 +963,7 @@ fn show_toolchain_version_nested_file_override() { let subdir = cwd.join("foo"); fs::create_dir_all(&subdir).unwrap(); - config.change_dir(&subdir, &|config| { + config.change_dir(&subdir, &|config| async move { config.expect_ok_ex( &["rustup", "show"], &format!( @@ -992,8 +995,8 @@ nightly-{0} (overridden by '{1}') #[test] #[ignore = "FIXME: Windows shows UNC paths"] fn show_toolchain_toolchain_file_override_not_installed() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); let cwd = config.current_dir(); @@ -1019,8 +1022,8 @@ fn show_toolchain_toolchain_file_override_not_installed() { #[test] async fn show_toolchain_override_not_installed() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_ok(&["rustup", "toolchain", "remove", "nightly"]); let mut cmd = clitools::cmd(config, "rustup", ["show"]); @@ -1038,8 +1041,8 @@ async fn show_toolchain_override_not_installed() { #[test] async fn override_set_unset_with_path() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = fs::canonicalize(config.current_dir()).unwrap(); let mut cwd_str = cwd.to_str().unwrap(); @@ -1048,7 +1051,7 @@ async fn override_set_unset_with_path() { } let emptydir = tempfile::tempdir().unwrap(); - config.change_dir(emptydir.path(), &|config| { + config.change_dir(emptydir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "set", "nightly", "--path", cwd_str]); }); config.expect_ok_ex( @@ -1056,7 +1059,7 @@ async fn override_set_unset_with_path() { &format!("{}\tnightly-{}\n", cwd_str, this_host_triple()), r"", ); - config.change_dir(emptydir.path(), &|config| { + config.change_dir(emptydir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "unset", "--path", cwd_str]); }); config.expect_ok_ex(&["rustup", "override", "list"], "no overrides\n", r""); @@ -1066,8 +1069,8 @@ async fn override_set_unset_with_path() { #[test] async fn show_toolchain_env() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); let out = config.run("rustup", ["show"], &[("RUSTUP_TOOLCHAIN", "nightly")]); assert!(out.ok); @@ -1089,8 +1092,8 @@ nightly-{0} (environment override by RUSTUP_TOOLCHAIN) #[test] async fn show_toolchain_env_not_installed() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let mut cmd = clitools::cmd(config, "rustup", ["show"]); clitools::env(config, &mut cmd); cmd.env("RUSTUP_TOOLCHAIN", "nightly"); @@ -1106,8 +1109,8 @@ async fn show_toolchain_env_not_installed() { #[test] async fn show_active_toolchain() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok_ex( &["rustup", "show", "active-toolchain"], @@ -1123,11 +1126,11 @@ async fn show_active_toolchain() { #[test] async fn show_with_verbose() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); }); - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "update", "nightly-2015-01-01"]); config.expect_ok_ex( &["rustup", "show", "--verbose"], @@ -1162,8 +1165,8 @@ nightly-{0} (default) #[test] async fn show_active_toolchain_with_verbose() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok_ex( &["rustup", "show", "active-toolchain", "--verbose"], @@ -1180,8 +1183,8 @@ async fn show_active_toolchain_with_verbose() { #[test] async fn show_active_toolchain_with_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "override", "set", "stable"]); @@ -1195,15 +1198,15 @@ async fn show_active_toolchain_with_override() { #[test] async fn show_active_toolchain_none() { - test(&|config| { + test(&|config| async move { config.expect_ok_ex(&["rustup", "show", "active-toolchain"], r"", r""); }); } #[test] async fn show_profile() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustup", "show", "profile"], "default"); @@ -1219,7 +1222,7 @@ async fn show_profile() { // #846 #[test] async fn set_default_host() { - test(&|config| { + test(&|config| async move { config.expect_ok(&["rustup", "set", "default-host", &this_host_triple()]); config.expect_stdout_ok(&["rustup", "show"], for_host!("Default host: {0}")); }); @@ -1228,7 +1231,7 @@ async fn set_default_host() { // #846 #[test] async fn set_default_host_invalid_triple() { - test(&|config| { + test(&|config| async move { config.expect_err( &["rustup", "set", "default-host", "foo"], "error: Provided host 'foo' couldn't be converted to partial triple", @@ -1239,7 +1242,7 @@ async fn set_default_host_invalid_triple() { // #745 #[test] async fn set_default_host_invalid_triple_valid_partial() { - test(&|config| { + test(&|config| async move { config.expect_err( &["rustup", "set", "default-host", "x86_64-msvc"], "error: Provided host 'x86_64-msvc' did not specify an operating system", @@ -1250,11 +1253,11 @@ async fn set_default_host_invalid_triple_valid_partial() { // #422 #[test] async fn update_doesnt_update_non_tracking_channels() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); }); - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "update", "nightly-2015-01-01"]); let mut cmd = clitools::cmd(config, "rustup", ["update"]); clitools::env(config, &mut cmd); @@ -1269,8 +1272,8 @@ async fn update_doesnt_update_non_tracking_channels() { #[test] async fn toolchain_install_is_like_update() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); config.expect_stdout_ok( &["rustup", "run", "nightly", "rustc", "--version"], @@ -1282,8 +1285,8 @@ async fn toolchain_install_is_like_update() { #[test] async fn toolchain_install_is_like_update_quiet() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "--quiet", "toolchain", "install", "nightly"]); config.expect_stdout_ok( &["rustup", "run", "nightly", "rustc", "--version"], @@ -1295,7 +1298,7 @@ async fn toolchain_install_is_like_update_quiet() { #[test] async fn toolchain_install_is_like_update_except_that_bare_install_is_an_error() { - test(&|config| { + test(&|config| async move { config.expect_err( &["rustup", "toolchain", "install"], "arguments were not provided", @@ -1305,8 +1308,8 @@ async fn toolchain_install_is_like_update_except_that_bare_install_is_an_error() #[test] async fn toolchain_update_is_like_update() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "toolchain", "update", "nightly"]); config.expect_stdout_ok( &["rustup", "run", "nightly", "rustc", "--version"], @@ -1318,8 +1321,8 @@ async fn toolchain_update_is_like_update() { #[test] async fn toolchain_uninstall_is_like_uninstall() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); }); config.expect_ok(&["rustup", "default", "none"]); @@ -1330,7 +1333,7 @@ async fn toolchain_uninstall_is_like_uninstall() { #[test] async fn toolchain_update_is_like_update_except_that_bare_install_is_an_error() { - test(&|config| { + test(&|config| async move { config.expect_err( &["rustup", "toolchain", "update"], "arguments were not provided", @@ -1340,8 +1343,8 @@ async fn toolchain_update_is_like_update_except_that_bare_install_is_an_error() #[test] async fn proxy_toolchain_shorthand() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "update", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); @@ -1353,8 +1356,8 @@ async fn proxy_toolchain_shorthand() { #[test] async fn add_component() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "component", "add", "rust-src"]); let path = format!( @@ -1368,8 +1371,8 @@ async fn add_component() { #[test] async fn remove_component() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "component", "add", "rust-src"]); let path = PathBuf::from(format!( @@ -1390,8 +1393,8 @@ async fn add_remove_multiple_components() { format!("lib/rustlib/{}/analysis/libfoo.json", this_host_triple()), ]; - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "component", "add", "rust-src", "rust-analysis"]); for file in &files { @@ -1413,8 +1416,8 @@ async fn add_remove_multiple_components() { #[test] async fn file_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1431,8 +1434,8 @@ async fn file_override() { #[test] async fn env_override_path() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1454,8 +1457,8 @@ async fn env_override_path() { #[test] async fn plus_override_relpath_is_not_supported() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1477,8 +1480,8 @@ async fn plus_override_relpath_is_not_supported() { #[test] async fn run_with_relpath_is_not_supported() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1502,8 +1505,8 @@ async fn run_with_relpath_is_not_supported() { #[test] async fn plus_override_abspath_is_supported() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1524,8 +1527,8 @@ async fn plus_override_abspath_is_supported() { #[test] async fn run_with_abspath_is_supported() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1548,8 +1551,8 @@ async fn run_with_abspath_is_supported() { #[test] async fn file_override_path() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1577,8 +1580,8 @@ async fn file_override_path() { #[test] async fn proxy_override_path() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1600,8 +1603,8 @@ async fn proxy_override_path() { #[test] async fn file_override_path_relative_not_supported() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1642,7 +1645,7 @@ async fn file_override_path_relative_not_supported() { // Change into an ephemeral dir so that we test that the path is relative to the override let ephemeral = config.current_dir().join("ephemeral"); fs::create_dir_all(&ephemeral).unwrap(); - config.change_dir(&ephemeral, &|config| { + config.change_dir(&ephemeral, &|config| async move { config.expect_err(&["rustc", "--version"], "relative path toolchain"); }); }) @@ -1651,7 +1654,7 @@ async fn file_override_path_relative_not_supported() { #[test] async fn file_override_path_no_options() { - test(&|config| { + test(&|config| async move { // Make a plausible-looking toolchain let cwd = config.current_dir(); let toolchain_path = cwd.join("ephemeral"); @@ -1696,7 +1699,7 @@ async fn file_override_path_no_options() { #[test] async fn file_override_path_xor_channel() { - test(&|config| { + test(&|config| async move { // Make a plausible-looking toolchain let cwd = config.current_dir(); let toolchain_path = cwd.join("ephemeral"); @@ -1719,8 +1722,8 @@ async fn file_override_path_xor_channel() { #[test] async fn file_override_subdir() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1732,7 +1735,7 @@ async fn file_override_subdir() { let subdir = cwd.join("subdir"); fs::create_dir_all(&subdir).unwrap(); - config.change_dir(&subdir, &|config| { + config.change_dir(&subdir, &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); }); }) @@ -1741,11 +1744,11 @@ async fn file_override_subdir() { #[test] async fn file_override_with_archive() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); }); - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "toolchain", "install", "nightly-2015-01-01"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); @@ -1761,11 +1764,11 @@ async fn file_override_with_archive() { #[test] async fn file_override_toml_format_select_installed_toolchain() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); }); - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_ok(&["rustup", "toolchain", "install", "nightly-2015-01-01"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); @@ -1788,11 +1791,11 @@ channel = "nightly-2015-01-01" #[test] async fn file_override_toml_format_install_both_toolchain_and_components() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); }); - config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| { + config.with_scenario(Scenario::ArchivesV2_2015_01_01, &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); config.expect_not_stdout_ok(&["rustup", "component", "list"], "rust-src (installed)"); @@ -1816,8 +1819,8 @@ components = [ "rust-src" ] #[test] async fn file_override_toml_format_add_missing_components() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_not_stdout_ok(&["rustup", "component", "list"], "rust-src (installed)"); @@ -1839,8 +1842,8 @@ components = [ "rust-src" ] #[test] async fn file_override_toml_format_add_missing_targets() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_not_stdout_ok( &["rustup", "component", "list"], @@ -1868,8 +1871,8 @@ targets = [ "arm-linux-androideabi" ] #[test] async fn file_override_toml_format_skip_invalid_component() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); let cwd = config.current_dir(); @@ -1893,8 +1896,8 @@ components = [ "rust-bongo" ] #[test] async fn file_override_toml_format_specify_profile() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "set", "profile", "default"]); config.expect_stderr_ok( &["rustup", "default", "stable"], @@ -1922,8 +1925,8 @@ channel = "nightly" #[test] async fn directory_override_beats_file_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "beta"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1942,8 +1945,8 @@ async fn directory_override_beats_file_override() { #[test] async fn close_file_override_beats_far_directory_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "beta"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -1959,7 +1962,7 @@ async fn close_file_override_beats_far_directory_override() { let toolchain_file = subdir.join("rust-toolchain"); raw::write_file(&toolchain_file, "nightly").unwrap(); - config.change_dir(&subdir, &|config| { + config.change_dir(&subdir, &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); }); }) @@ -1968,8 +1971,8 @@ async fn close_file_override_beats_far_directory_override() { #[test] async fn directory_override_doesnt_need_to_exist_unless_it_is_selected() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "beta"]); // not installing nightly @@ -1988,8 +1991,8 @@ async fn directory_override_doesnt_need_to_exist_unless_it_is_selected() { #[test] async fn env_override_beats_file_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "beta"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -2012,8 +2015,8 @@ async fn env_override_beats_file_override() { #[test] async fn plus_override_beats_file_override() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "beta"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -2029,7 +2032,7 @@ async fn plus_override_beats_file_override() { #[test] async fn file_override_not_installed_custom() { - test(&|config| { + test(&|config| async move { let cwd = config.current_dir(); let toolchain_file = cwd.join("rust-toolchain"); raw::write_file(&toolchain_file, "gumbo").unwrap(); @@ -2040,7 +2043,7 @@ async fn file_override_not_installed_custom() { #[test] async fn bad_file_override() { - test(&|config| { + test(&|config| async move { let cwd = config.current_dir(); let toolchain_file = cwd.join("rust-toolchain"); // invalid name - cannot specify no toolchain in a toolchain file @@ -2052,8 +2055,8 @@ async fn bad_file_override() { #[test] async fn valid_override_settings() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = config.current_dir(); let toolchain_file = cwd.join("rust-toolchain"); config.expect_ok(&["rustup", "default", "nightly"]); @@ -2084,7 +2087,7 @@ async fn valid_override_settings() { async fn file_override_with_target_info() { // Target info is not portable between machines, so we reject toolchain // files that include it. - test(&|config| { + test(&|config| async move { let cwd = config.current_dir(); let toolchain_file = cwd.join("rust-toolchain"); raw::write_file(&toolchain_file, "nightly-x86_64-unknown-linux-gnu").unwrap(); @@ -2098,8 +2101,8 @@ async fn file_override_with_target_info() { #[test] async fn docs_with_path() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -2120,8 +2123,8 @@ async fn docs_with_path() { #[test] async fn docs_topical_with_path() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); @@ -2144,8 +2147,8 @@ async fn docs_topical_with_path() { #[test] async fn docs_missing() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "set", "profile", "minimal"]); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( @@ -2158,7 +2161,7 @@ async fn docs_missing() { #[test] async fn docs_custom() { - test(&|config| { + test(&|config| async move { let path = config.customdir.join("custom-1"); let path = path.to_string_lossy(); config.expect_ok(&["rustup", "toolchain", "link", "custom", &path]); @@ -2173,8 +2176,8 @@ async fn non_utf8_arg() { use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); let out = config.run( "rustc", @@ -2196,8 +2199,8 @@ async fn non_utf8_arg() { use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); let out = config.run( "rustc", @@ -2219,8 +2222,8 @@ async fn non_utf8_toolchain() { use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); let out = config.run( "rustc", @@ -2238,8 +2241,8 @@ async fn non_utf8_toolchain() { use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); let out = config.run( "rustc", @@ -2253,11 +2256,11 @@ async fn non_utf8_toolchain() { #[test] async fn check_host_goes_away() { - test(&|config| { - config.with_scenario(Scenario::HostGoesMissingBefore, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::HostGoesMissingBefore, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); }); - config.with_scenario(Scenario::HostGoesMissingAfter, &|config| { + config.with_scenario(Scenario::HostGoesMissingAfter, &|config| async move { config.expect_err( &["rustup", "update", "nightly"], for_host!("target '{}' not found in channel"), @@ -2269,8 +2272,8 @@ async fn check_host_goes_away() { #[cfg(unix)] #[test] async fn check_unix_settings_fallback() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { // No default toolchain specified yet config.expect_err(&["rustup", "default"], r"no default toolchain configured"); @@ -2304,8 +2307,8 @@ async fn check_unix_settings_fallback() { #[test] async fn warn_on_unmatch_build() { - test(&|config| { - config.with_scenario(Scenario::MultiHost, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::MultiHost, &|config| async move { let arch = clitools::MULTI_ARCH1; config.expect_stderr_ok( &["rustup", "toolchain", "install", &format!("nightly-{arch}")], @@ -2320,8 +2323,8 @@ warning: If you meant to build software to target that platform, perhaps try `ru #[test] async fn dont_warn_on_partial_build() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let triple = this_host_triple().await; let arch = triple.split('-').next().unwrap(); let mut cmd = clitools::cmd( @@ -2346,8 +2349,8 @@ async fn dont_warn_on_partial_build() { /// Checks that `rust-toolchain.toml` files are considered #[test] async fn rust_toolchain_toml() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_err( &["rustc", "--version"], "rustup could not choose a version of rustc to run", @@ -2365,8 +2368,8 @@ async fn rust_toolchain_toml() { /// Ensures that `rust-toolchain.toml` files (with `.toml` extension) only allow TOML contents #[test] async fn only_toml_in_rust_toolchain_toml() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = config.current_dir(); let toolchain_file = cwd.join("rust-toolchain.toml"); raw::write_file(&toolchain_file, "nightly").unwrap(); @@ -2379,8 +2382,8 @@ async fn only_toml_in_rust_toolchain_toml() { /// Checks that a warning occurs if both `rust-toolchain` and `rust-toolchain.toml` files exist #[test] async fn warn_on_duplicate_rust_toolchain_file() { - test(&|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + test(&|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { let cwd = config.current_dir(); let toolchain_file_1 = cwd.join("rust-toolchain"); raw::write_file(&toolchain_file_1, "stable").unwrap(); diff --git a/tests/suite/cli_self_upd.rs b/tests/suite/cli_self_upd.rs index ec76e2e9dd8..eb53a9d234b 100644 --- a/tests/suite/cli_self_upd.rs +++ b/tests/suite/cli_self_upd.rs @@ -25,13 +25,13 @@ use rustup_macros::integration_test as test; const TEST_VERSION: &str = "1.1.1"; -pub fn update_setup(f: &dyn Fn(&mut Config, &Path)) { +pub async fn update_setup(f: &dyn Fn(&mut Config, &Path)) { self_update_setup(f, TEST_VERSION) } /// Empty dist server, rustup installed with no toolchain -fn setup_empty_installed(f: &dyn Fn(&mut Config)) { - clitools::test(Scenario::Empty, &|config| { +async fn setup_empty_installed(f: &dyn Fn(&mut Config)) { + clitools::test(Scenario::Empty, &|config| async move { config.expect_ok(&[ "rustup-init", "-y", @@ -44,8 +44,8 @@ fn setup_empty_installed(f: &dyn Fn(&mut Config)) { } /// SimpleV3 dist server, rustup installed with default toolchain -fn setup_installed(f: &dyn Fn(&mut Config)) { - clitools::test(Scenario::SimpleV2, &|config| { +async fn setup_installed(f: &dyn Fn(&mut Config)) { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); f(config); }) @@ -56,18 +56,19 @@ fn setup_installed(f: &dyn Fn(&mut Config)) { /// installation code path: everything that is output, the proxy installation, /// status of the proxies. async fn install_bins_to_cargo_home() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { with_saved_path(&mut || { - config.expect_ok_contains( - &["rustup-init", "-y"], - for_host!( - r" + Box::pin(async move { + config.expect_ok_contains( + &["rustup-init", "-y"], + for_host!( + r" stable-{0} installed - 1.1.0 (hash-stable-1.1.0) " - ), - for_host!( - r"info: syncing channel updates for 'stable-{0}' + ), + for_host!( + r"info: syncing channel updates for 'stable-{0}' info: latest update on 2015-01-02, rust version 1.1.0 (hash-stable-1.1.0) info: downloading component 'cargo' info: downloading component 'rust-docs' @@ -79,33 +80,34 @@ info: installing component 'rust-std' info: installing component 'rustc' info: default toolchain set to 'stable-{0}' " - ), - ); - #[cfg(windows)] - fn check(path: &Path) { - assert!(path.exists()); - } - #[cfg(not(windows))] - fn check(path: &Path) { - fn is_exe(path: &Path) -> bool { - use std::os::unix::fs::MetadataExt; - let mode = path.metadata().unwrap().mode(); - mode & 0o777 == 0o755 + ), + ); + #[cfg(windows)] + fn check(path: &Path) { + assert!(path.exists()); + } + #[cfg(not(windows))] + fn check(path: &Path) { + fn is_exe(path: &Path) -> bool { + use std::os::unix::fs::MetadataExt; + let mode = path.metadata().unwrap().mode(); + mode & 0o777 == 0o755 + } + assert!(is_exe(path)); } - assert!(is_exe(path)); - } - for tool in TOOLS.iter().chain(DUP_TOOLS.iter()) { - let path = &config.cargodir.join(&format!("bin/{tool}{EXE_SUFFIX}")); - check(path); - } + for tool in TOOLS.iter().chain(DUP_TOOLS.iter()) { + let path = &config.cargodir.join(&format!("bin/{tool}{EXE_SUFFIX}")); + check(path); + } + }) }) }); } #[test] async fn install_twice() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { with_saved_path(&mut || { config.expect_ok(&["rustup-init", "-y"]); config.expect_ok(&["rustup-init", "-y"]); @@ -120,7 +122,7 @@ async fn install_twice() { /// depending just on unit tests here could miss subtle dependencies being added /// earlier in the code, so a black-box test is needed. async fn install_creates_cargo_home() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { remove_dir_all(&config.cargodir).unwrap(); config.rustupdir.remove().unwrap(); config.expect_ok(&[ @@ -138,7 +140,7 @@ async fn install_creates_cargo_home() { /// Functional test needed here - we need to do the full dance where we start /// with rustup.exe and end up deleting that exe itself. async fn uninstall_deletes_bins() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { // no-modify-path isn't needed here, as the test-dir-path isn't present // in the registry, so the no-change code path will be triggered. config.expect_ok(&["rustup", "self", "uninstall", "-y"]); @@ -161,7 +163,7 @@ async fn uninstall_deletes_bins() { #[test] async fn uninstall_works_if_some_bins_dont_exist() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { let rustup = config.cargodir.join(format!("bin/rustup{EXE_SUFFIX}")); let rustc = config.cargodir.join(format!("bin/rustc{EXE_SUFFIX}")); let rustdoc = config.cargodir.join(format!("bin/rustdoc{EXE_SUFFIX}")); @@ -187,7 +189,7 @@ async fn uninstall_works_if_some_bins_dont_exist() { #[test] async fn uninstall_deletes_rustup_home() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { config.expect_ok(&["rustup", "self", "uninstall", "-y"]); assert!(!config.rustupdir.has(".")); }); @@ -195,7 +197,7 @@ async fn uninstall_deletes_rustup_home() { #[test] async fn uninstall_works_if_rustup_home_doesnt_exist() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { config.rustupdir.remove().unwrap(); config.expect_ok(&["rustup", "self", "uninstall", "-y"]); }); @@ -203,7 +205,7 @@ async fn uninstall_works_if_rustup_home_doesnt_exist() { #[test] async fn uninstall_deletes_cargo_home() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { config.expect_ok(&["rustup", "self", "uninstall", "-y"]); assert!(!config.cargodir.exists()); }); @@ -211,7 +213,7 @@ async fn uninstall_deletes_cargo_home() { #[test] async fn uninstall_fails_if_not_installed() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { let rustup = config.cargodir.join(format!("bin/rustup{EXE_SUFFIX}")); fs::remove_file(rustup).unwrap(); config.expect_err( @@ -227,7 +229,7 @@ async fn uninstall_fails_if_not_installed() { #[test] #[cfg_attr(target_os = "macos", ignore)] // FIXME #1515 async fn uninstall_self_delete_works() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { let rustup = config.cargodir.join(format!("bin/rustup{EXE_SUFFIX}")); let mut cmd = Command::new(rustup.clone()); cmd.args(["self", "uninstall", "-y"]); @@ -259,7 +261,7 @@ async fn uninstall_self_delete_works() { // file in CONFIG.CARGODIR/.. ; check that it doesn't exist. #[test] async fn uninstall_doesnt_leave_gc_file() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { config.expect_ok(&["rustup", "self", "uninstall", "-y"]); let parent = config.cargodir.parent().unwrap(); @@ -474,25 +476,28 @@ async fn rustup_no_self_update_with_specified_toolchain() { #[test] async fn rustup_self_update_exact() { update_setup(&|config, _| { - config.expect_ok(&["rustup", "set", "auto-self-update", "enable"]); - config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); + { + config.expect_ok(&["rustup", "set", "auto-self-update", "enable"]); + config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); - config.expect_ok_ex( - &["rustup", "update"], - for_host!( - r" + config.expect_ok_ex( + &["rustup", "update"], + for_host!( + r" stable-{0} unchanged - 1.1.0 (hash-stable-1.1.0) " - ), - for_host!( - r"info: syncing channel updates for 'stable-{0}' + ), + for_host!( + r"info: syncing channel updates for 'stable-{0}' info: checking for self-update info: downloading self-update info: cleaning up downloads & tmp directories " - ), - ); + ), + ); + } + .into() }) } @@ -555,7 +560,7 @@ async fn rustup_still_works_after_update() { // still needs to work in that mode. #[test] async fn as_rustup_setup() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { let init = config.exedir.join(format!("rustup-init{EXE_SUFFIX}")); let setup = config.exedir.join(format!("rustup-setup{EXE_SUFFIX}")); fs::copy(init, setup).unwrap(); @@ -571,7 +576,7 @@ async fn as_rustup_setup() { #[test] async fn reinstall_exact() { - setup_empty_installed(&|config| { + setup_empty_installed(&|config| async move { config.expect_stderr_ok( &[ "rustup-init", @@ -586,7 +591,7 @@ async fn reinstall_exact() { #[test] async fn reinstall_specifying_toolchain() { - setup_installed(&|config| { + setup_installed(&|config| async move { config.expect_stdout_ok( &[ "rustup-init", @@ -601,7 +606,7 @@ async fn reinstall_specifying_toolchain() { #[test] async fn reinstall_specifying_component() { - setup_installed(&|config| { + setup_installed(&|config| async move { config.expect_ok(&["rustup", "component", "add", "rls"]); config.expect_stdout_ok( &[ @@ -617,7 +622,7 @@ async fn reinstall_specifying_component() { #[test] async fn reinstall_specifying_different_toolchain() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_stderr_ok( &[ "rustup-init", @@ -632,7 +637,7 @@ async fn reinstall_specifying_different_toolchain() { #[test] async fn install_sets_up_stable_unless_a_different_default_is_requested() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_ok(&[ "rustup-init", "-y", @@ -646,7 +651,7 @@ async fn install_sets_up_stable_unless_a_different_default_is_requested() { #[test] async fn install_sets_up_stable_unless_there_is_already_a_default() { - setup_installed(&|config| { + setup_installed(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "toolchain", "remove", "stable"]); config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); @@ -660,7 +665,7 @@ async fn install_sets_up_stable_unless_there_is_already_a_default() { #[test] async fn readline_no_stdin() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_err( &["rustup-init", "--no-modify-path"], "unable to read from stdin for confirmation", @@ -671,7 +676,7 @@ async fn readline_no_stdin() { #[test] async fn rustup_init_works_with_weird_names() { // Browsers often rename bins to e.g. rustup-init(2).exe. - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { let old = config.exedir.join(format!("rustup-init{EXE_SUFFIX}")); let new = config.exedir.join(format!("rustup-init(2){EXE_SUFFIX}")); fs::rename(old, new).unwrap(); @@ -683,7 +688,7 @@ async fn rustup_init_works_with_weird_names() { #[test] async fn install_but_rustup_sh_is_installed() { - clitools::test(Scenario::Empty, &|config| { + clitools::test(Scenario::Empty, &|config| async move { config.create_rustup_sh_metadata(); config.expect_stderr_ok( &[ @@ -700,7 +705,7 @@ async fn install_but_rustup_sh_is_installed() { #[test] async fn test_warn_succeed_if_rustup_sh_already_installed_y_flag() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.create_rustup_sh_metadata(); let out = config.run("rustup-init", ["-y", "--no-modify-path"], &[]); assert!(out.ok); @@ -719,7 +724,7 @@ async fn test_warn_succeed_if_rustup_sh_already_installed_y_flag() { #[test] async fn test_succeed_if_rustup_sh_already_installed_env_var_set() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.create_rustup_sh_metadata(); let out = config.run( "rustup-init", @@ -742,8 +747,8 @@ async fn test_succeed_if_rustup_sh_already_installed_env_var_set() { #[test] async fn rls_proxy_set_up_after_install() { - clitools::test(Scenario::None, &|config| { - config.with_scenario(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::None, &|config| async move { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_ok(&["rustup-init", "-y", "--no-modify-path"]); }); config.expect_err( @@ -824,7 +829,7 @@ async fn update_installs_clippy_cargo_and() { #[test] async fn install_with_components_and_targets() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_ok(&[ "rustup-init", "--default-toolchain", @@ -849,7 +854,7 @@ async fn install_with_components_and_targets() { #[test] async fn install_minimal_profile() { - clitools::test(Scenario::SimpleV2, &|config| { + clitools::test(Scenario::SimpleV2, &|config| async move { config.expect_ok(&[ "rustup-init", "-y", diff --git a/tests/suite/cli_v1.rs b/tests/suite/cli_v1.rs index 665c0a7b588..4d9975fa786 100644 --- a/tests/suite/cli_v1.rs +++ b/tests/suite/cli_v1.rs @@ -8,13 +8,13 @@ use rustup_macros::integration_test as test; use rustup::test::mock::clitools::{self, set_current_dist_date, Config, Scenario}; -pub fn setup(f: &dyn Fn(&mut Config)) { +pub async fn setup(f: &dyn Fn(&mut Config)) { clitools::test(Scenario::SimpleV1, f); } #[test] async fn rustc_no_default_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustc"], "rustup could not choose a version of rustc to run", @@ -24,7 +24,7 @@ async fn rustc_no_default_toolchain() { #[test] async fn expected_bins_exist() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "1.3.0"); }); @@ -32,7 +32,7 @@ async fn expected_bins_exist() { #[test] async fn install_toolchain_from_channel() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); config.expect_ok(&["rustup", "default", "beta"]); @@ -44,7 +44,7 @@ async fn install_toolchain_from_channel() { #[test] async fn install_toolchain_from_archive() { - clitools::test(Scenario::ArchivesV1, &|config| { + clitools::test(Scenario::ArchivesV1, &|config| async move { config.expect_ok(&["rustup", "default", "nightly-2015-01-01"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-1"); config.expect_ok(&["rustup", "default", "beta-2015-01-01"]); @@ -56,7 +56,7 @@ async fn install_toolchain_from_archive() { #[test] async fn install_toolchain_from_version() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "1.1.0"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); }); @@ -64,7 +64,7 @@ async fn install_toolchain_from_version() { #[test] async fn default_existing_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_stderr_ok( &["rustup", "default", "nightly"], @@ -75,7 +75,7 @@ async fn default_existing_toolchain() { #[test] async fn update_channel() { - clitools::test(Scenario::ArchivesV1, &|config| { + clitools::test(Scenario::ArchivesV1, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-1"); @@ -87,7 +87,7 @@ async fn update_channel() { #[test] async fn list_toolchains() { - clitools::test(Scenario::ArchivesV1, &|config| { + clitools::test(Scenario::ArchivesV1, &|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_ok(&["rustup", "update", "beta-2015-01-01"]); config.expect_stdout_ok(&["rustup", "toolchain", "list"], "nightly"); @@ -118,14 +118,14 @@ async fn list_toolchains() { #[test] async fn list_toolchains_with_none() { - setup(&|config| { + setup(&|config| async move { config.expect_stdout_ok(&["rustup", "toolchain", "list"], "no installed toolchains"); }); } #[test] async fn remove_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_ok(&["rustup", "toolchain", "remove", "nightly"]); config.expect_ok(&["rustup", "toolchain", "list"]); @@ -135,7 +135,7 @@ async fn remove_toolchain() { #[test] async fn remove_default_toolchain_autoinstalls() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "toolchain", "remove", "nightly"]); config.expect_stderr_ok(&["rustc", "--version"], "info: installing component"); @@ -144,9 +144,9 @@ async fn remove_default_toolchain_autoinstalls() { #[test] async fn remove_override_toolchain_err_handling() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "override", "add", "beta"]); config.expect_ok(&["rustup", "toolchain", "remove", "beta"]); @@ -157,7 +157,7 @@ async fn remove_override_toolchain_err_handling() { #[test] async fn bad_sha_on_manifest() { - setup(&|config| { + setup(&|config| async move { let sha_file = config .distdir .as_ref() @@ -174,7 +174,7 @@ async fn bad_sha_on_manifest() { #[test] async fn bad_sha_on_installer() { - setup(&|config| { + setup(&|config| async move { let dir = config.distdir.as_ref().unwrap().join("dist"); for file in fs::read_dir(&dir).unwrap() { let file = file.unwrap(); @@ -190,7 +190,7 @@ async fn bad_sha_on_installer() { #[test] async fn install_override_toolchain_from_channel() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); config.expect_ok(&["rustup", "override", "add", "beta"]); @@ -202,7 +202,7 @@ async fn install_override_toolchain_from_channel() { #[test] async fn install_override_toolchain_from_archive() { - clitools::test(Scenario::ArchivesV1, &|config| { + clitools::test(Scenario::ArchivesV1, &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly-2015-01-01"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-1"); config.expect_ok(&["rustup", "override", "add", "beta-2015-01-01"]); @@ -214,7 +214,7 @@ async fn install_override_toolchain_from_archive() { #[test] async fn install_override_toolchain_from_version() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "override", "add", "1.1.0"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); }); @@ -222,10 +222,10 @@ async fn install_override_toolchain_from_version() { #[test] async fn override_overrides_default() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.expect_ok(&["rustup", "default", "nightly"]); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "beta"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-beta-1.2.0"); }); @@ -234,24 +234,24 @@ async fn override_overrides_default() { #[test] async fn multiple_overrides() { - setup(&|config| { + setup(&|config| async move { let tempdir1 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tempdir2 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.expect_ok(&["rustup", "default", "nightly"]); - config.change_dir(tempdir1.path(), &|config| { + config.change_dir(tempdir1.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "beta"]); }); - config.change_dir(tempdir2.path(), &|config| { + config.change_dir(tempdir2.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "stable"]); }); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); - config.change_dir(tempdir1.path(), &|config| { + config.change_dir(tempdir1.path(), &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-beta-1.2.0"); }); - config.change_dir(tempdir2.path(), &|config| { + config.change_dir(tempdir2.path(), &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); }); }); @@ -259,9 +259,9 @@ async fn multiple_overrides() { #[test] async fn change_override() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_ok(&["rustup", "override", "add", "beta"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-beta-1.2.0"); @@ -271,9 +271,9 @@ async fn change_override() { #[test] async fn remove_override_no_default() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_ok(&["rustup", "override", "remove"]); config.expect_err( @@ -286,9 +286,9 @@ async fn remove_override_no_default() { #[test] async fn remove_override_with_default() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "override", "add", "beta"]); config.expect_ok(&["rustup", "override", "remove"]); @@ -299,22 +299,22 @@ async fn remove_override_with_default() { #[test] async fn remove_override_with_multiple_overrides() { - setup(&|config| { + setup(&|config| async move { let tempdir1 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tempdir2 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.expect_ok(&["rustup", "default", "nightly"]); - config.change_dir(tempdir1.path(), &|config| { + config.change_dir(tempdir1.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "beta"]); }); - config.change_dir(tempdir2.path(), &|config| { + config.change_dir(tempdir2.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "stable"]); }); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); - config.change_dir(tempdir1.path(), &|config| { + config.change_dir(tempdir1.path(), &|config| async move { config.expect_ok(&["rustup", "override", "remove"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); }); - config.change_dir(tempdir2.path(), &|config| { + config.change_dir(tempdir2.path(), &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); }); }); @@ -322,7 +322,7 @@ async fn remove_override_with_multiple_overrides() { #[test] async fn no_update_on_channel_when_date_has_not_changed() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_stdout_ok(&["rustup", "update", "nightly"], "unchanged"); }); @@ -330,7 +330,7 @@ async fn no_update_on_channel_when_date_has_not_changed() { #[test] async fn update_on_channel_when_date_has_changed() { - clitools::test(Scenario::ArchivesV1, &|config| { + clitools::test(Scenario::ArchivesV1, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-1"); @@ -342,7 +342,7 @@ async fn update_on_channel_when_date_has_changed() { #[test] async fn run_command() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_ok(&["rustup", "default", "beta"]); config.expect_stdout_ok( @@ -355,7 +355,7 @@ async fn run_command() { #[test] async fn remove_toolchain_then_add_again() { // Issue brson/multirust #53 - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "beta"]); config.expect_ok(&["rustup", "toolchain", "remove", "beta"]); config.expect_ok(&["rustup", "update", "beta"]); diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index 8e7f71a4d6f..f1e31462f54 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -10,17 +10,17 @@ use rustup::test::mock::clitools::{self, set_current_dist_date, Config, Scenario use rustup::test::this_host_triple; use rustup_macros::integration_test as test; -pub fn setup(f: &dyn Fn(&mut Config)) { +pub async fn setup(f: &dyn Fn(&mut Config)) { clitools::test(Scenario::SimpleV2, f); } -pub fn setup_complex(f: &dyn Fn(&mut Config)) { +pub async fn setup_complex(f: &dyn Fn(&mut Config)) { clitools::test(Scenario::UnavailableRls, f); } #[test] async fn rustc_no_default_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustc"], "rustup could not choose a version of rustc to run", @@ -30,7 +30,7 @@ async fn rustc_no_default_toolchain() { #[test] async fn expected_bins_exist() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "1.3.0"); }); @@ -38,7 +38,7 @@ async fn expected_bins_exist() { #[test] async fn install_toolchain_from_channel() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); config.expect_ok(&["rustup", "default", "beta"]); @@ -50,7 +50,7 @@ async fn install_toolchain_from_channel() { #[test] async fn install_toolchain_from_archive() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { config.expect_ok(&["rustup", "default", "nightly-2015-01-01"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-1"); config.expect_ok(&["rustup", "default", "beta-2015-01-01"]); @@ -62,7 +62,7 @@ async fn install_toolchain_from_archive() { #[test] async fn install_toolchain_from_version() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "1.1.0"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); }); @@ -70,7 +70,7 @@ async fn install_toolchain_from_version() { #[test] async fn install_with_profile() { - setup_complex(&|config| { + setup_complex(&|config| async move { // Start with a config that uses the "complete" profile set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "set", "profile", "complete"]); @@ -102,7 +102,7 @@ async fn install_with_profile() { #[test] async fn default_existing_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_stderr_ok( &["rustup", "default", "nightly"], @@ -113,7 +113,7 @@ async fn default_existing_toolchain() { #[test] async fn update_channel() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-1"); @@ -125,7 +125,7 @@ async fn update_channel() { #[test] async fn list_toolchains() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_ok(&["rustup", "update", "beta-2015-01-01"]); config.expect_stdout_ok(&["rustup", "toolchain", "list"], "nightly"); @@ -157,7 +157,7 @@ async fn list_toolchains() { #[test] async fn list_toolchains_with_bogus_file() { // #520 - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); let name = "bogus_regular_file.txt"; @@ -170,14 +170,14 @@ async fn list_toolchains_with_bogus_file() { #[test] async fn list_toolchains_with_none() { - setup(&|config| { + setup(&|config| async move { config.expect_stdout_ok(&["rustup", "toolchain", "list"], "no installed toolchains"); }); } #[test] async fn remove_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_ok(&["rustup", "toolchain", "remove", "nightly"]); config.expect_ok(&["rustup", "toolchain", "list"]); @@ -188,7 +188,7 @@ async fn remove_toolchain() { // Issue #2873 #[test] async fn remove_toolchain_ignore_trailing_slash() { - setup(&|config| { + setup(&|config| async move { // custom toolchain name with trailing slash let path = config.customdir.join("custom-1"); let path_str = path.to_string_lossy(); @@ -212,7 +212,7 @@ async fn remove_toolchain_ignore_trailing_slash() { #[test] async fn add_remove_multiple_toolchains() { fn go(add: &str, rm: &str) { - setup(&|config| { + setup(&|config| async move { let tch1 = "beta"; let tch2 = "nightly"; @@ -237,7 +237,7 @@ async fn add_remove_multiple_toolchains() { #[test] async fn remove_default_toolchain_autoinstalls() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "toolchain", "remove", "nightly"]); config.expect_stderr_ok(&["rustc", "--version"], "info: installing component"); @@ -246,9 +246,9 @@ async fn remove_default_toolchain_autoinstalls() { #[test] async fn remove_override_toolchain_err_handling() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "override", "add", "beta"]); config.expect_ok(&["rustup", "toolchain", "remove", "beta"]); @@ -259,7 +259,7 @@ async fn remove_override_toolchain_err_handling() { #[test] async fn file_override_toolchain_err_handling() { - setup(&|config| { + setup(&|config| async move { let cwd = config.current_dir(); let toolchain_file = cwd.join("rust-toolchain"); rustup::utils::raw::write_file(&toolchain_file, "beta").unwrap(); @@ -269,7 +269,7 @@ async fn file_override_toolchain_err_handling() { #[test] async fn plus_override_toolchain_err_handling() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustc", "+beta"], for_host!("toolchain 'beta-{0}' is not installed"), @@ -279,7 +279,7 @@ async fn plus_override_toolchain_err_handling() { #[test] async fn bad_sha_on_manifest() { - setup(&|config| { + setup(&|config| async move { // Corrupt the sha let sha_file = config .distdir @@ -301,7 +301,7 @@ async fn bad_sha_on_manifest() { #[test] async fn bad_sha_on_installer() { - setup(&|config| { + setup(&|config| async move { // Since the v2 sha's are contained in the manifest, corrupt the installer let dir = config.distdir.as_ref().unwrap().join("dist/2015-01-02"); for file in fs::read_dir(&dir).unwrap() { @@ -321,7 +321,7 @@ async fn bad_sha_on_installer() { #[test] async fn install_override_toolchain_from_channel() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); config.expect_ok(&["rustup", "override", "add", "beta"]); @@ -333,7 +333,7 @@ async fn install_override_toolchain_from_channel() { #[test] async fn install_override_toolchain_from_archive() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly-2015-01-01"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-1"); config.expect_ok(&["rustup", "override", "add", "beta-2015-01-01"]); @@ -345,7 +345,7 @@ async fn install_override_toolchain_from_archive() { #[test] async fn install_override_toolchain_from_version() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "override", "add", "1.1.0"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); }); @@ -353,10 +353,10 @@ async fn install_override_toolchain_from_version() { #[test] async fn override_overrides_default() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.expect_ok(&["rustup", "default", "nightly"]); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "beta"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-beta-1.2.0"); }); @@ -365,24 +365,24 @@ async fn override_overrides_default() { #[test] async fn multiple_overrides() { - setup(&|config| { + setup(&|config| async move { let tempdir1 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tempdir2 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.expect_ok(&["rustup", "default", "nightly"]); - config.change_dir(tempdir1.path(), &|config| { + config.change_dir(tempdir1.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "beta"]); }); - config.change_dir(tempdir2.path(), &|config| { + config.change_dir(tempdir2.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "stable"]); }); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); - config.change_dir(tempdir1.path(), &|config| { + config.change_dir(tempdir1.path(), &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-beta-1.2.0"); }); - config.change_dir(tempdir2.path(), &|config| { + config.change_dir(tempdir2.path(), &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); }); }); @@ -392,7 +392,7 @@ async fn multiple_overrides() { #[test] #[cfg(windows)] async fn override_windows_root() { - setup(&|config| { + setup(&|config| async move { use std::path::{Component, PathBuf}; let cwd = config.current_dir(); @@ -406,7 +406,7 @@ async fn override_windows_root() { // Really sketchy to be messing with C:\ in a test... let prefix = prefix.as_os_str().to_str().unwrap(); let prefix = format!("{prefix}\\"); - config.change_dir(&PathBuf::from(&prefix), &|config| { + config.change_dir(&PathBuf::from(&prefix), &|config| async move { config.expect_ok(&["rustup", "default", "stable"]); config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); @@ -418,9 +418,9 @@ async fn override_windows_root() { #[test] async fn change_override() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_ok(&["rustup", "override", "add", "beta"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-beta-1.2.0"); @@ -430,9 +430,9 @@ async fn change_override() { #[test] async fn remove_override_no_default() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "nightly"]); config.expect_ok(&["rustup", "override", "remove"]); config.expect_err( @@ -445,9 +445,9 @@ async fn remove_override_no_default() { #[test] async fn remove_override_with_default() { - setup(&|config| { + setup(&|config| async move { let tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); - config.change_dir(tempdir.path(), &|config| { + config.change_dir(tempdir.path(), &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "override", "add", "beta"]); config.expect_ok(&["rustup", "override", "remove"]); @@ -458,22 +458,22 @@ async fn remove_override_with_default() { #[test] async fn remove_override_with_multiple_overrides() { - setup(&|config| { + setup(&|config| async move { let tempdir1 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); let tempdir2 = tempfile::Builder::new().prefix("rustup").tempdir().unwrap(); config.expect_ok(&["rustup", "default", "nightly"]); - config.change_dir(tempdir1.path(), &|config| { + config.change_dir(tempdir1.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "beta"]); }); - config.change_dir(tempdir2.path(), &|config| { + config.change_dir(tempdir2.path(), &|config| async move { config.expect_ok(&["rustup", "override", "add", "stable"]); }); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); - config.change_dir(tempdir1.path(), &|config| { + config.change_dir(tempdir1.path(), &|config| async move { config.expect_ok(&["rustup", "override", "remove"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-2"); }); - config.change_dir(tempdir2.path(), &|config| { + config.change_dir(tempdir2.path(), &|config| async move { config.expect_stdout_ok(&["rustc", "--version"], "hash-stable-1.1.0"); }); }); @@ -481,7 +481,7 @@ async fn remove_override_with_multiple_overrides() { #[test] async fn no_update_on_channel_when_date_has_not_changed() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_stdout_ok(&["rustup", "update", "nightly"], "unchanged"); }); @@ -489,7 +489,7 @@ async fn no_update_on_channel_when_date_has_not_changed() { #[test] async fn update_on_channel_when_date_has_changed() { - clitools::test(Scenario::ArchivesV2, &|config| { + clitools::test(Scenario::ArchivesV2, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustc", "--version"], "hash-nightly-1"); @@ -501,7 +501,7 @@ async fn update_on_channel_when_date_has_changed() { #[test] async fn run_command() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_ok(&["rustup", "default", "beta"]); config.expect_stdout_ok( @@ -514,7 +514,7 @@ async fn run_command() { #[test] async fn remove_toolchain_then_add_again() { // Issue brson/multirust #53 - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "beta"]); config.expect_ok(&["rustup", "toolchain", "remove", "beta"]); config.expect_ok(&["rustup", "update", "beta"]); @@ -524,7 +524,7 @@ async fn remove_toolchain_then_add_again() { #[test] async fn upgrade_v1_to_v2() { - clitools::test(Scenario::Full, &|config| { + clitools::test(Scenario::Full, &|config| async move { set_current_dist_date(config, "2015-01-01"); // Delete the v2 manifest so the first day we install from the v1s fs::remove_file( @@ -545,7 +545,7 @@ async fn upgrade_v1_to_v2() { #[test] async fn upgrade_v2_to_v1() { - clitools::test(Scenario::Full, &|config| { + clitools::test(Scenario::Full, &|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "default", "nightly"]); set_current_dist_date(config, "2015-01-02"); @@ -566,7 +566,7 @@ async fn upgrade_v2_to_v1() { #[test] async fn list_targets_no_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &["rustup", "target", "list", "--toolchain=nightly"], for_host!("toolchain 'nightly-{0}' is not installed"), @@ -576,7 +576,7 @@ async fn list_targets_no_toolchain() { #[test] async fn list_targets_v1_toolchain() { - clitools::test(Scenario::SimpleV1, &|config| { + clitools::test(Scenario::SimpleV1, &|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_err( &["rustup", "target", "list", "--toolchain=nightly"], @@ -587,7 +587,7 @@ async fn list_targets_v1_toolchain() { #[test] async fn list_targets_custom_toolchain() { - setup(&|config| { + setup(&|config| async move { let path = config.customdir.join("custom-1"); let path = path.to_string_lossy(); config.expect_ok(&["rustup", "toolchain", "link", "default-from-path", &path]); @@ -601,7 +601,7 @@ async fn list_targets_custom_toolchain() { #[test] async fn list_targets() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_stdout_ok(&["rustup", "target", "list"], clitools::CROSS_ARCH1); config.expect_stdout_ok(&["rustup", "target", "list"], clitools::CROSS_ARCH2); @@ -610,7 +610,7 @@ async fn list_targets() { #[test] async fn list_installed_targets() { - setup(&|config| { + setup(&|config| async move { let trip = this_host_triple().await; config.expect_ok(&["rustup", "default", "nightly"]); @@ -620,7 +620,7 @@ async fn list_installed_targets() { #[test] async fn add_target1() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "add", clitools::CROSS_ARCH1]); let path = format!( @@ -634,7 +634,7 @@ async fn add_target1() { #[test] async fn add_target2() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "add", clitools::CROSS_ARCH2]); let path = format!( @@ -648,7 +648,7 @@ async fn add_target2() { #[test] async fn add_all_targets() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "add", "all"]); let path = format!( @@ -668,7 +668,7 @@ async fn add_all_targets() { #[test] async fn add_all_targets_fail() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( &[ @@ -690,7 +690,7 @@ async fn add_all_targets_fail() { #[test] async fn add_target_by_component_add() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_not_stdout_ok( &["rustup", "target", "list"], @@ -711,7 +711,7 @@ async fn add_target_by_component_add() { #[test] async fn remove_target_by_component_remove() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "add", clitools::CROSS_ARCH1]); config.expect_stdout_ok( @@ -733,7 +733,7 @@ async fn remove_target_by_component_remove() { #[test] async fn add_target_no_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &[ "rustup", @@ -748,7 +748,7 @@ async fn add_target_no_toolchain() { } #[test] async fn add_target_bogus() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( &["rustup", "target", "add", "bogus"], @@ -761,7 +761,7 @@ async fn add_target_bogus() { #[test] async fn add_target_v1_toolchain() { - clitools::test(Scenario::SimpleV1, &|config| { + clitools::test(Scenario::SimpleV1, &|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); config.expect_err( &[ @@ -778,7 +778,7 @@ async fn add_target_v1_toolchain() { #[test] async fn add_target_custom_toolchain() { - setup(&|config| { + setup(&|config| async move { let path = config.customdir.join("custom-1"); let path = path.to_string_lossy(); config.expect_ok(&["rustup", "toolchain", "link", "default-from-path", &path]); @@ -792,7 +792,7 @@ async fn add_target_custom_toolchain() { #[test] async fn cannot_add_empty_named_custom_toolchain() { - setup(&|config| { + setup(&|config| async move { let path = config.customdir.join("custom-1"); let path = path.to_string_lossy(); config.expect_err( @@ -804,7 +804,7 @@ async fn cannot_add_empty_named_custom_toolchain() { #[test] async fn add_target_again() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "add", clitools::CROSS_ARCH1]); config.expect_stderr_ok( @@ -825,7 +825,7 @@ async fn add_target_again() { #[test] async fn add_target_host() { - setup(&|config| { + setup(&|config| async move { let trip = this_host_triple().await; config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "add", &trip]); @@ -834,7 +834,7 @@ async fn add_target_host() { #[test] async fn remove_target() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "add", clitools::CROSS_ARCH1]); config.expect_ok(&["rustup", "target", "remove", clitools::CROSS_ARCH1]); @@ -861,7 +861,7 @@ async fn remove_target() { #[test] async fn remove_target_not_installed() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( &["rustup", "target", "remove", clitools::CROSS_ARCH1], @@ -876,7 +876,7 @@ async fn remove_target_not_installed() { #[test] async fn remove_target_no_toolchain() { - setup(&|config| { + setup(&|config| async move { config.expect_err( &[ "rustup", @@ -892,7 +892,7 @@ async fn remove_target_no_toolchain() { #[test] async fn remove_target_bogus() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( &["rustup", "target", "remove", "bogus"], @@ -903,7 +903,7 @@ async fn remove_target_bogus() { #[test] async fn remove_target_v1_toolchain() { - clitools::test(Scenario::SimpleV1, &|config| { + clitools::test(Scenario::SimpleV1, &|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( &[ @@ -920,7 +920,7 @@ async fn remove_target_v1_toolchain() { #[test] async fn remove_target_custom_toolchain() { - setup(&|config| { + setup(&|config| async move { let path = config.customdir.join("custom-1"); let path = path.to_string_lossy(); config.expect_ok(&["rustup", "toolchain", "link", "default-from-path", &path]); @@ -934,7 +934,7 @@ async fn remove_target_custom_toolchain() { #[test] async fn remove_target_again() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "add", clitools::CROSS_ARCH1]); config.expect_ok(&["rustup", "target", "remove", clitools::CROSS_ARCH1]); @@ -951,7 +951,7 @@ async fn remove_target_again() { #[test] async fn remove_target_host() { - setup(&|config| { + setup(&|config| async move { let trip = this_host_triple().await; config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&["rustup", "target", "remove", &trip]); @@ -961,7 +961,7 @@ async fn remove_target_host() { #[test] // Issue #304 async fn remove_target_missing_update_hash() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "update", "nightly"]); let file_name = format!("nightly-{}", this_host_triple()); @@ -974,7 +974,7 @@ async fn remove_target_missing_update_hash() { // Issue #1777 #[test] async fn warn_about_and_remove_stray_hash() { - clitools::test(Scenario::None, &|config| { + clitools::test(Scenario::None, &|config| async move { let mut hash_path = config.rustupdir.join("update-hashes"); fs::create_dir_all(&hash_path).expect("Unable to make the update-hashes directory"); hash_path.push(for_host!("nightly-{}")); @@ -983,7 +983,7 @@ async fn warn_about_and_remove_stray_hash() { .expect("Unable to write update-hash"); drop(file); - config.with_scenario(Scenario::SimpleV2, &|config| { + config.with_scenario(Scenario::SimpleV2, &|config| async move { config.expect_stderr_ok( &["rustup", "toolchain", "install", "nightly"], &format!( @@ -1023,7 +1023,7 @@ fn make_component_unavailable(config: &Config, name: &str, target: &str) { #[test] async fn update_unavailable_std() { - setup(&|config| { + setup(&|config| async move { make_component_unavailable(config, "rust-std", &this_host_triple()); config.expect_err( &["rustup", "update", "nightly", ], @@ -1036,7 +1036,7 @@ async fn update_unavailable_std() { #[test] async fn add_missing_component_toolchain() { - setup(&|config| { + setup(&|config| async move { make_component_unavailable(config, "rust-std", &this_host_triple()); config.expect_err( &["rustup", "toolchain", "add", "nightly"], @@ -1052,7 +1052,7 @@ Sometimes not all components are available in any given nightly. If you don't ne #[test] async fn update_unavailable_force() { - setup(&|config| { + setup(&|config| async move { let trip = this_host_triple().await; config.expect_ok(&["rustup", "update", "nightly"]); config.expect_ok(&[ @@ -1076,7 +1076,7 @@ async fn update_unavailable_force() { #[test] async fn add_component_suggest_best_match() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( &["rustup", "component", "add", "rsl"], @@ -1096,7 +1096,7 @@ async fn add_component_suggest_best_match() { #[test] async fn remove_component_suggest_best_match() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_not_stderr_err( &["rustup", "component", "remove", "rsl"], @@ -1121,7 +1121,7 @@ async fn remove_component_suggest_best_match() { #[test] async fn add_target_suggest_best_match() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_err( &[ @@ -1138,7 +1138,7 @@ async fn add_target_suggest_best_match() { #[test] async fn remove_target_suggest_best_match() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_not_stderr_err( &[ @@ -1164,7 +1164,7 @@ async fn remove_target_suggest_best_match() { #[test] async fn target_list_ignores_unavailable_targets() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); let target_list = &["rustup", "target", "list"]; config.expect_stdout_ok(target_list, clitools::CROSS_ARCH1); @@ -1180,7 +1180,7 @@ async fn install_with_components() { let mut args = vec!["rustup", "toolchain", "install", "nightly"]; args.extend_from_slice(comp_args); - setup(&|config| { + setup(&|config| async move { config.expect_ok(&args); config.expect_stdout_ok(&["rustup", "component", "list"], "rust-src (installed)"); config.expect_stdout_ok( @@ -1200,7 +1200,7 @@ async fn install_with_targets() { let mut args = vec!["rustup", "toolchain", "install", "nightly"]; args.extend_from_slice(comp_args); - setup(&|config| { + setup(&|config| async move { config.expect_ok(&args); config.expect_stdout_ok( &["rustup", "target", "list"], @@ -1222,7 +1222,7 @@ async fn install_with_targets() { #[test] async fn install_with_component_and_target() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "default", "nightly"]); config.expect_ok(&[ "rustup", @@ -1247,7 +1247,7 @@ async fn install_with_component_and_target() { #[test] async fn test_warn_if_complete_profile_is_used() { - setup(&|config| { + setup(&|config| async move { config.expect_ok(&["rustup", "set", "auto-self-update", "enable"]); config.expect_err( &[ @@ -1265,7 +1265,7 @@ async fn test_warn_if_complete_profile_is_used() { #[test] async fn test_complete_profile_skips_missing_when_forced() { - setup_complex(&|config| { + setup_complex(&|config| async move { set_current_dist_date(config, "2015-01-01"); config.expect_ok(&["rustup", "set", "profile", "complete"]); @@ -1295,7 +1295,7 @@ async fn test_complete_profile_skips_missing_when_forced() { #[test] async fn run_with_install_flag_against_unavailable_component() { - setup(&|config| { + setup(&|config| async move { let trip = this_host_triple().await; make_component_unavailable(config, "rust-std", &trip); config.expect_ok_ex( @@ -1327,7 +1327,7 @@ info: installing component 'rustc' #[test] async fn install_allow_downgrade() { - clitools::test(Scenario::MissingComponent, &|config| { + clitools::test(Scenario::MissingComponent, &|config| async move { let trip = this_host_triple().await; // this dist has no rls and there is no newer one @@ -1362,7 +1362,7 @@ async fn install_allow_downgrade() { #[test] async fn regression_2601() { // We're checking that we don't regress per #2601 - setup(&|config| { + setup(&|config| async move { config.expect_ok(&[ "rustup", "toolchain",