Skip to content

Commit 33ee857

Browse files
committed
Prep setup_from_dist_server for async support
1 parent 71a991c commit 33ee857

1 file changed

Lines changed: 28 additions & 21 deletions

File tree

‎src/dist/manifestation/tests.rs‎

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::str::FromStr;
1111
use std::sync::Arc;
1212

1313
use anyhow::{anyhow, Result};
14+
use tokio::runtime::Builder;
1415
use url::Url;
1516

1617
use rustup_macros::unit_test as test;
@@ -537,37 +538,43 @@ fn setup_from_dist_server(
537538
comps.enable_xz(),
538539
comps.enable_zst(),
539540
);
540-
541541
let prefix_tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap();
542-
543542
let work_tempdir = tempfile::Builder::new().prefix("rustup").tempdir().unwrap();
544543
let temp_cfg = temp::Cfg::new(
545544
work_tempdir.path().to_owned(),
546545
DEFAULT_DIST_SERVER,
547546
Box::new(|_| ()),
548547
);
549-
550548
let toolchain = ToolchainDesc::from_str("nightly-x86_64-apple-darwin").unwrap();
551549
let prefix = InstallPrefix::from(prefix_tempdir.path());
552-
let download_cfg = DownloadCfg {
553-
dist_root: "phony",
554-
temp_cfg: &temp_cfg,
555-
download_dir: &prefix.path().to_owned().join("downloads"),
556-
notify_handler: &|event| {
557-
println!("{event}");
558-
},
559-
};
560550

561-
currentprocess::with(
562-
currentprocess::TestProcess::new(
563-
env::current_dir().unwrap(),
564-
&["rustup"],
565-
HashMap::default(),
566-
"",
567-
)
568-
.into(),
569-
|| f(url, &toolchain, &prefix, &download_cfg, &temp_cfg),
570-
);
551+
let tp = currentprocess::TestProcess::new(
552+
env::current_dir().unwrap(),
553+
&["rustup"],
554+
HashMap::default(),
555+
"",
556+
)
557+
.into();
558+
559+
let mut builder = Builder::new_multi_thread();
560+
builder
561+
.enable_all()
562+
.worker_threads(2)
563+
.max_blocking_threads(2);
564+
565+
currentprocess::with_runtime(tp, builder, {
566+
async move {
567+
let download_cfg = DownloadCfg {
568+
dist_root: "phony",
569+
temp_cfg: &temp_cfg,
570+
download_dir: &prefix.path().to_owned().join("downloads"),
571+
notify_handler: &|event| {
572+
println!("{event}");
573+
},
574+
};
575+
f(url, &toolchain, &prefix, &download_cfg, &temp_cfg)
576+
}
577+
});
571578
}
572579

573580
fn initial_install(comps: Compressions) {

0 commit comments

Comments
 (0)