@@ -393,6 +393,27 @@ fn update_from_dist(dist_server: &Url,
393
393
download_cfg : & DownloadCfg ,
394
394
temp_cfg : & temp:: Cfg ) -> Result < UpdateStatus > {
395
395
396
+ update_from_dist_ (
397
+ dist_server,
398
+ toolchain,
399
+ prefix,
400
+ add,
401
+ remove,
402
+ download_cfg,
403
+ temp_cfg,
404
+ false ,
405
+ )
406
+ }
407
+
408
+ fn update_from_dist_ ( dist_server : & Url ,
409
+ toolchain : & ToolchainDesc ,
410
+ prefix : & InstallPrefix ,
411
+ add : & [ Component ] ,
412
+ remove : & [ Component ] ,
413
+ download_cfg : & DownloadCfg ,
414
+ temp_cfg : & temp:: Cfg ,
415
+ force_update : bool ) -> Result < UpdateStatus > {
416
+
396
417
// Download the dist manifest and place it into the installation prefix
397
418
let ref manifest_url = try!( make_manifest_url ( dist_server, toolchain) ) ;
398
419
let manifest_file = try!( temp_cfg. new_file ( ) ) ;
@@ -412,7 +433,7 @@ fn update_from_dist(dist_server: &Url,
412
433
manifestation. update (
413
434
& manifest,
414
435
changes,
415
- false ,
436
+ force_update ,
416
437
download_cfg,
417
438
download_cfg. notify_handler . clone ( ) ,
418
439
)
@@ -520,8 +541,8 @@ fn upgrade() {
520
541
}
521
542
522
543
#[ test]
523
- fn update_removes_components_that_dont_exist ( ) {
524
- // On day 1 install the 'bonus' component, on day 2 its no londer a component
544
+ fn force_update ( ) {
545
+ // On day 1 install the 'bonus' component, on day 2 its no longer a component
525
546
let edit = & |date : & str , pkg : & mut MockPackage | {
526
547
if date == "2016-02-01" {
527
548
let mut tpkg = pkg. targets . iter_mut ( ) . find ( |p| p. target == "x86_64-apple-darwin" ) . unwrap ( ) ;
@@ -531,12 +552,22 @@ fn update_removes_components_that_dont_exist() {
531
552
} ) ;
532
553
}
533
554
} ;
555
+
534
556
setup ( Some ( edit) , false , & |url, toolchain, prefix, download_cfg, temp_cfg| {
535
557
change_channel_date ( url, "nightly" , "2016-02-01" ) ;
558
+ // Update with bonus.
536
559
update_from_dist ( url, toolchain, prefix, & [ ] , & [ ] , download_cfg, temp_cfg) . unwrap ( ) ;
537
560
assert ! ( utils:: path_exists( & prefix. path( ) . join( "bin/bonus" ) ) ) ;
538
561
change_channel_date ( url, "nightly" , "2016-02-02" ) ;
539
- update_from_dist ( url, toolchain, prefix, & [ ] , & [ ] , download_cfg, temp_cfg) . unwrap ( ) ;
562
+
563
+ // Update without bonus, should fail.
564
+ let err = update_from_dist ( url, toolchain, prefix, & [ ] , & [ ] , download_cfg, temp_cfg) . unwrap_err ( ) ;
565
+ match * err. kind ( ) {
566
+ ErrorKind :: RequestedComponentsUnavailable ( ..) => { } ,
567
+ _ => panic ! ( )
568
+ }
569
+ // Force update without bonus, should succeed, but bonus binary will be missing.
570
+ update_from_dist_ ( url, toolchain, prefix, & [ ] , & [ ] , download_cfg, temp_cfg, true ) . unwrap ( ) ;
540
571
assert ! ( !utils:: path_exists( & prefix. path( ) . join( "bin/bonus" ) ) ) ;
541
572
} ) ;
542
573
}
0 commit comments