@@ -350,38 +350,37 @@ fn create_local_update_server(self_dist: &Path, exedir: &Path, version: &str) ->
350
350
}
351
351
352
352
pub fn self_update_setup ( f : & dyn Fn ( & mut Config , & Path ) , version : & str ) {
353
- test ( Scenario :: SimpleV2 , & |config| {
354
- // Create a mock self-update server
353
+ let mut cx = CliTestContext :: from ( Scenario :: SimpleV2 ) ;
355
354
356
- let self_dist_tmp = tempfile:: Builder :: new ( )
357
- . prefix ( "self_dist" )
358
- . tempdir_in ( & config. test_root_dir )
359
- . unwrap ( ) ;
360
- let self_dist = self_dist_tmp. path ( ) ;
361
-
362
- let root_url = create_local_update_server ( self_dist, & config. exedir , version) ;
363
- config. rustup_update_root = Some ( root_url) ;
364
-
365
- let trip = this_host_triple ( ) ;
366
- let dist_dir = self_dist. join ( format ! ( "archive/{version}/{trip}" ) ) ;
367
- let dist_exe = dist_dir. join ( format ! ( "rustup-init{EXE_SUFFIX}" ) ) ;
368
- let dist_tmp = dist_dir. join ( "rustup-init-tmp" ) ;
369
-
370
- // Modify the exe so it hashes different
371
- // 1) move out of the way the file
372
- fs:: rename ( & dist_exe, & dist_tmp) . unwrap ( ) ;
373
- // 2) copy it
374
- fs:: copy ( dist_tmp, & dist_exe) . unwrap ( ) ;
375
- // modify it
376
- let mut dest_file = fs:: OpenOptions :: new ( )
377
- . append ( true )
378
- . create ( true )
379
- . open ( dist_exe)
380
- . unwrap ( ) ;
381
- writeln ! ( dest_file) . unwrap ( ) ;
355
+ // Create a mock self-update server
356
+ let self_dist_tmp = tempfile:: Builder :: new ( )
357
+ . prefix ( "self_dist" )
358
+ . tempdir_in ( & cx. config . test_root_dir )
359
+ . unwrap ( ) ;
360
+ let self_dist = self_dist_tmp. path ( ) ;
382
361
383
- f ( config, self_dist) ;
384
- } ) ;
362
+ let root_url = create_local_update_server ( self_dist, & cx. config . exedir , version) ;
363
+ cx. config . rustup_update_root = Some ( root_url) ;
364
+
365
+ let trip = this_host_triple ( ) ;
366
+ let dist_dir = self_dist. join ( format ! ( "archive/{version}/{trip}" ) ) ;
367
+ let dist_exe = dist_dir. join ( format ! ( "rustup-init{EXE_SUFFIX}" ) ) ;
368
+ let dist_tmp = dist_dir. join ( "rustup-init-tmp" ) ;
369
+
370
+ // Modify the exe so it hashes different
371
+ // 1) move out of the way the file
372
+ fs:: rename ( & dist_exe, & dist_tmp) . unwrap ( ) ;
373
+ // 2) copy it
374
+ fs:: copy ( dist_tmp, & dist_exe) . unwrap ( ) ;
375
+ // modify it
376
+ let mut dest_file = fs:: OpenOptions :: new ( )
377
+ . append ( true )
378
+ . create ( true )
379
+ . open ( dist_exe)
380
+ . unwrap ( ) ;
381
+ writeln ! ( dest_file) . unwrap ( ) ;
382
+
383
+ f ( & mut cx. config , self_dist) ;
385
384
}
386
385
387
386
pub fn with_update_server ( config : & mut Config , version : & str , f : & dyn Fn ( & mut Config ) ) {
0 commit comments