Skip to content

Commit c180842

Browse files
committed
Add test for xz tarballs
1 parent 7934e53 commit c180842

File tree

9 files changed

+110
-54
lines changed

9 files changed

+110
-54
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rustup-dist/tests/dist.rs

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fn mock_dist_server_smoke_test() {
246246
let tempdir = TempDir::new("multirust").unwrap();
247247
let path = tempdir.path();
248248

249-
create_mock_dist_server(&path, None).write(&[ManifestVersion::V2]);
249+
create_mock_dist_server(&path, None).write(&[ManifestVersion::V2], false);
250250

251251
assert!(utils::path_exists(path.join("dist/2016-02-01/rustc-nightly-x86_64-apple-darwin.tar.gz")));
252252
assert!(utils::path_exists(path.join("dist/2016-02-01/rustc-nightly-i686-apple-darwin.tar.gz")));
@@ -308,10 +308,10 @@ fn uninstall(toolchain: &ToolchainDesc, prefix: &InstallPrefix, temp_cfg: &temp:
308308
Ok(())
309309
}
310310

311-
fn setup(edit: Option<&Fn(&str, &mut MockPackage)>,
311+
fn setup(edit: Option<&Fn(&str, &mut MockPackage)>, enable_xz: bool,
312312
f: &Fn(&Url, &ToolchainDesc, &InstallPrefix, &dist::DownloadCfg, &temp::Cfg)) {
313313
let dist_tempdir = TempDir::new("multirust").unwrap();
314-
create_mock_dist_server(dist_tempdir.path(), edit).write(&[ManifestVersion::V2]);
314+
create_mock_dist_server(dist_tempdir.path(), edit).write(&[ManifestVersion::V2], enable_xz);
315315

316316
let prefix_tempdir = TempDir::new("multirust").unwrap();
317317

@@ -335,7 +335,17 @@ fn setup(edit: Option<&Fn(&str, &mut MockPackage)>,
335335

336336
#[test]
337337
fn initial_install() {
338-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
338+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
339+
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
340+
341+
assert!(utils::path_exists(&prefix.path().join("bin/rustc")));
342+
assert!(utils::path_exists(&prefix.path().join("lib/libstd.rlib")));
343+
});
344+
}
345+
346+
#[test]
347+
fn initial_install_xz() {
348+
setup(None, true, &|url, toolchain, prefix, download_cfg, temp_cfg| {
339349
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
340350

341351
assert!(utils::path_exists(&prefix.path().join("bin/rustc")));
@@ -345,7 +355,7 @@ fn initial_install() {
345355

346356
#[test]
347357
fn test_uninstall() {
348-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
358+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
349359
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
350360
uninstall(toolchain, prefix, temp_cfg, &|_| ()).unwrap();
351361

@@ -356,7 +366,7 @@ fn test_uninstall() {
356366

357367
#[test]
358368
fn uninstall_removes_config_file() {
359-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
369+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
360370
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
361371
assert!(utils::path_exists(&prefix.manifest_file("multirust-config.toml")));
362372
uninstall(toolchain, prefix, temp_cfg, &|_| ()).unwrap();
@@ -366,7 +376,7 @@ fn uninstall_removes_config_file() {
366376

367377
#[test]
368378
fn upgrade() {
369-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
379+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
370380
change_channel_date(url, "nightly", "2016-02-01");
371381
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
372382
assert_eq!("2016-02-01", utils_raw::read_file(&prefix.path().join("bin/rustc")).unwrap());
@@ -388,7 +398,7 @@ fn update_removes_components_that_dont_exist() {
388398
});
389399
}
390400
};
391-
setup(Some(edit), &|url, toolchain, prefix, download_cfg, temp_cfg| {
401+
setup(Some(edit), false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
392402
change_channel_date(url, "nightly", "2016-02-01");
393403
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
394404
assert!(utils::path_exists(&prefix.path().join("bin/bonus")));
@@ -400,7 +410,7 @@ fn update_removes_components_that_dont_exist() {
400410

401411
#[test]
402412
fn update_preserves_extensions() {
403-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
413+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
404414
let ref adds = vec![
405415
Component {
406416
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -442,7 +452,7 @@ fn update_preserves_extensions_that_became_components() {
442452
});
443453
}
444454
};
445-
setup(Some(edit), &|url, toolchain, prefix, download_cfg, temp_cfg| {
455+
setup(Some(edit), false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
446456
let ref adds = vec![
447457
Component {
448458
pkg: "bonus".to_string(), target: Some(TargetTriple::from_str("x86_64-apple-darwin"))
@@ -478,7 +488,7 @@ fn update_preserves_components_that_became_extensions() {
478488
});
479489
}
480490
};
481-
setup(Some(edit), &|url, toolchain, prefix, download_cfg, temp_cfg| {
491+
setup(Some(edit), false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
482492
change_channel_date(url, "nightly", "2016-02-01");
483493
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
484494
assert!(utils::path_exists(&prefix.path().join("bin/bonus")));
@@ -490,7 +500,7 @@ fn update_preserves_components_that_became_extensions() {
490500

491501
#[test]
492502
fn update_makes_no_changes_for_identical_manifest() {
493-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
503+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
494504
let status = update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
495505
assert_eq!(status, UpdateStatus::Changed);
496506
let status = update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
@@ -500,7 +510,7 @@ fn update_makes_no_changes_for_identical_manifest() {
500510

501511
#[test]
502512
fn add_extensions_for_initial_install() {
503-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
513+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
504514
let ref adds = vec![
505515
Component {
506516
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -518,7 +528,7 @@ fn add_extensions_for_initial_install() {
518528

519529
#[test]
520530
fn add_extensions_for_same_manifest() {
521-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
531+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
522532
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
523533

524534
let ref adds = vec![
@@ -539,7 +549,7 @@ fn add_extensions_for_same_manifest() {
539549

540550
#[test]
541551
fn add_extensions_for_upgrade() {
542-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
552+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
543553
change_channel_date(url, "nightly", "2016-02-01");
544554

545555
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
@@ -565,7 +575,7 @@ fn add_extensions_for_upgrade() {
565575
#[test]
566576
#[should_panic]
567577
fn add_extension_not_in_manifest() {
568-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
578+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
569579
let ref adds = vec![
570580
Component {
571581
pkg: "rust-bogus".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -579,7 +589,7 @@ fn add_extension_not_in_manifest() {
579589
#[test]
580590
#[should_panic]
581591
fn add_extension_that_is_required_component() {
582-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
592+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
583593
let ref adds = vec![
584594
Component {
585595
pkg: "rustc".to_string(), target: Some(TargetTriple::from_str("x86_64-apple-darwin"))
@@ -602,7 +612,7 @@ fn add_extensions_for_same_manifest_when_extension_already_installed() {
602612

603613
#[test]
604614
fn add_extensions_does_not_remove_other_components() {
605-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
615+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
606616
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
607617

608618
let ref adds = vec![
@@ -621,7 +631,7 @@ fn add_extensions_does_not_remove_other_components() {
621631
#[test]
622632
#[should_panic]
623633
fn remove_extensions_for_initial_install() {
624-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
634+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
625635
let ref removes = vec![
626636
Component {
627637
pkg: "rustc".to_string(), target: Some(TargetTriple::from_str("x86_64-apple-darwin"))
@@ -634,7 +644,7 @@ fn remove_extensions_for_initial_install() {
634644

635645
#[test]
636646
fn remove_extensions_for_same_manifest() {
637-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
647+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
638648
let ref adds = vec![
639649
Component {
640650
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -661,7 +671,7 @@ fn remove_extensions_for_same_manifest() {
661671

662672
#[test]
663673
fn remove_extensions_for_upgrade() {
664-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
674+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
665675
change_channel_date(url, "nightly", "2016-02-01");
666676

667677
let ref adds = vec![
@@ -693,7 +703,7 @@ fn remove_extensions_for_upgrade() {
693703
#[test]
694704
#[should_panic]
695705
fn remove_extension_not_in_manifest() {
696-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
706+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
697707
change_channel_date(url, "nightly", "2016-02-01");
698708

699709
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
@@ -725,7 +735,7 @@ fn remove_extension_not_in_manifest_but_is_already_installed() {
725735
});
726736
}
727737
};
728-
setup(Some(edit), &|url, toolchain, prefix, download_cfg, temp_cfg| {
738+
setup(Some(edit), false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
729739
change_channel_date(url, "nightly", "2016-02-01");
730740

731741
let ref adds = vec![
@@ -750,7 +760,7 @@ fn remove_extension_not_in_manifest_but_is_already_installed() {
750760
#[test]
751761
#[should_panic]
752762
fn remove_extension_that_is_required_component() {
753-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
763+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
754764
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
755765

756766
let ref removes = vec![
@@ -766,7 +776,7 @@ fn remove_extension_that_is_required_component() {
766776
#[test]
767777
#[should_panic]
768778
fn remove_extension_not_installed() {
769-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
779+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
770780
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
771781

772782
let ref removes = vec![
@@ -786,7 +796,7 @@ fn remove_extensions_for_same_manifest_does_not_reinstall_other_components() {
786796

787797
#[test]
788798
fn remove_extensions_does_not_remove_other_components() {
789-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
799+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
790800
let ref adds = vec![
791801
Component {
792802
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -809,7 +819,7 @@ fn remove_extensions_does_not_remove_other_components() {
809819

810820
#[test]
811821
fn add_and_remove_for_upgrade() {
812-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
822+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
813823
change_channel_date(url, "nightly", "2016-02-01");
814824

815825
let ref adds = vec![
@@ -843,7 +853,7 @@ fn add_and_remove_for_upgrade() {
843853

844854
#[test]
845855
fn add_and_remove() {
846-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
856+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
847857
let ref adds = vec![
848858
Component {
849859
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-unknown-linux-gnu"))
@@ -874,7 +884,7 @@ fn add_and_remove() {
874884
#[test]
875885
#[should_panic]
876886
fn add_and_remove_same_component() {
877-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
887+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
878888
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg, &|_| ()).unwrap();
879889

880890
let ref adds = vec![
@@ -895,7 +905,7 @@ fn add_and_remove_same_component() {
895905

896906
#[test]
897907
fn bad_component_hash() {
898-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
908+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
899909
let path = url.to_file_path().unwrap();
900910
let path = path.join("dist/2016-02-02/rustc-nightly-x86_64-apple-darwin.tar.gz");
901911
utils_raw::write_file(&path, "bogus").unwrap();
@@ -911,7 +921,7 @@ fn bad_component_hash() {
911921

912922
#[test]
913923
fn unable_to_download_component() {
914-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
924+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
915925
let path = url.to_file_path().unwrap();
916926
let path = path.join("dist/2016-02-02/rustc-nightly-x86_64-apple-darwin.tar.gz");
917927
fs::remove_file(&path).unwrap();
@@ -938,7 +948,7 @@ fn allow_installation(prefix: &InstallPrefix) {
938948

939949
#[test]
940950
fn reuse_downloaded_file() {
941-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
951+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
942952

943953
prevent_installation(prefix);
944954

@@ -959,7 +969,7 @@ fn reuse_downloaded_file() {
959969

960970
#[test]
961971
fn checks_files_hashes_before_reuse() {
962-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
972+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
963973

964974
let path = url.to_file_path().unwrap();
965975
let target_hash = utils::read_file("target hash", &path.join("dist/2016-02-02/rustc-nightly-x86_64-apple-darwin.tar.gz.sha256")).unwrap()[.. 64].to_owned();

src/rustup-mock/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ scopeguard = "0.1.2"
1515
lazy_static = "0.1.15"
1616
walkdir = "0.1.5"
1717
flate2 = "0.2.9"
18+
xz2 = "0.1.3"
1819
tempdir = "0.3.4"
1920
itertools = "0.4.1"
2021
tar = "0.4.0"

src/rustup-mock/src/clitools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
334334
MockDistServer {
335335
path: path.to_owned(),
336336
channels: chans,
337-
}.write(vs);
337+
}.write(vs, true);
338338

339339
// Also create the manifests for stable releases by version
340340
if s == Scenario::Full || s == Scenario::ArchivesV1 || s == Scenario::ArchivesV2 {

0 commit comments

Comments
 (0)