@@ -417,16 +417,33 @@ struct TestContext {
417
417
418
418
impl TestContext {
419
419
fn new ( edit : Option < & dyn Fn ( & str , & mut MockChannel ) > , comps : Compressions ) -> Self {
420
+ Self :: with_env ( edit, comps, HashMap :: new ( ) )
421
+ }
422
+
423
+ fn with_env (
424
+ edit : Option < & dyn Fn ( & str , & mut MockChannel ) > ,
425
+ comps : Compressions ,
426
+ env : HashMap < String , String > ,
427
+ ) -> Self {
420
428
let dist_tempdir = tempfile:: Builder :: new ( ) . prefix ( "rustup" ) . tempdir ( ) . unwrap ( ) ;
421
429
let mock_dist_server = create_mock_dist_server ( dist_tempdir. path ( ) , edit) ;
422
430
let url = Url :: parse ( & format ! ( "file://{}" , dist_tempdir. path( ) . to_string_lossy( ) ) ) . unwrap ( ) ;
423
431
424
- let mut cx = Self :: from_dist_server ( mock_dist_server, url, comps) ;
432
+ let mut cx = Self :: from_dist_server_with_env ( mock_dist_server, url, comps, env ) ;
425
433
cx. _tempdirs . push ( dist_tempdir) ;
426
434
cx
427
435
}
428
436
429
437
fn from_dist_server ( server : MockDistServer , url : Url , comps : Compressions ) -> Self {
438
+ Self :: from_dist_server_with_env ( server, url, comps, HashMap :: new ( ) )
439
+ }
440
+
441
+ fn from_dist_server_with_env (
442
+ server : MockDistServer ,
443
+ url : Url ,
444
+ comps : Compressions ,
445
+ env : HashMap < String , String > ,
446
+ ) -> Self {
430
447
server. write (
431
448
& [ MockManifestVersion :: V2 ] ,
432
449
comps. enable_xz ( ) ,
@@ -444,12 +461,7 @@ impl TestContext {
444
461
445
462
let toolchain = ToolchainDesc :: from_str ( "nightly-x86_64-apple-darwin" ) . unwrap ( ) ;
446
463
let prefix = InstallPrefix :: from ( prefix_tempdir. path ( ) ) ;
447
- let tp = TestProcess :: new (
448
- env:: current_dir ( ) . unwrap ( ) ,
449
- & [ "rustup" ] ,
450
- HashMap :: default ( ) ,
451
- "" ,
452
- ) ;
464
+ let tp = TestProcess :: new ( env:: current_dir ( ) . unwrap ( ) , & [ "rustup" ] , env, "" ) ;
453
465
454
466
Self {
455
467
url,
0 commit comments