Skip to content

Commit f3aeab3

Browse files
committed
Add test for xz tarballs
1 parent 462d719 commit f3aeab3

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")));
@@ -307,10 +307,10 @@ fn uninstall(toolchain: &ToolchainDesc, prefix: &InstallPrefix, temp_cfg: &temp:
307307
Ok(())
308308
}
309309

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

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

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

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

340350
assert!(utils::path_exists(&prefix.path().join("bin/rustc")));
@@ -344,7 +354,7 @@ fn initial_install() {
344354

345355
#[test]
346356
fn test_uninstall() {
347-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
357+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
348358
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
349359
uninstall(toolchain, prefix, temp_cfg, &|_| ()).unwrap();
350360

@@ -355,7 +365,7 @@ fn test_uninstall() {
355365

356366
#[test]
357367
fn uninstall_removes_config_file() {
358-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
368+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
359369
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
360370
assert!(utils::path_exists(&prefix.manifest_file("multirust-config.toml")));
361371
uninstall(toolchain, prefix, temp_cfg, &|_| ()).unwrap();
@@ -365,7 +375,7 @@ fn uninstall_removes_config_file() {
365375

366376
#[test]
367377
fn upgrade() {
368-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
378+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
369379
change_channel_date(url, "nightly", "2016-02-01");
370380
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
371381
assert_eq!("2016-02-01", utils_raw::read_file(&prefix.path().join("bin/rustc")).unwrap());
@@ -387,7 +397,7 @@ fn update_removes_components_that_dont_exist() {
387397
});
388398
}
389399
};
390-
setup(Some(edit), &|url, toolchain, prefix, download_cfg, temp_cfg| {
400+
setup(Some(edit), false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
391401
change_channel_date(url, "nightly", "2016-02-01");
392402
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
393403
assert!(utils::path_exists(&prefix.path().join("bin/bonus")));
@@ -399,7 +409,7 @@ fn update_removes_components_that_dont_exist() {
399409

400410
#[test]
401411
fn update_preserves_extensions() {
402-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
412+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
403413
let ref adds = vec![
404414
Component {
405415
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -441,7 +451,7 @@ fn update_preserves_extensions_that_became_components() {
441451
});
442452
}
443453
};
444-
setup(Some(edit), &|url, toolchain, prefix, download_cfg, temp_cfg| {
454+
setup(Some(edit), false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
445455
let ref adds = vec![
446456
Component {
447457
pkg: "bonus".to_string(), target: Some(TargetTriple::from_str("x86_64-apple-darwin"))
@@ -477,7 +487,7 @@ fn update_preserves_components_that_became_extensions() {
477487
});
478488
}
479489
};
480-
setup(Some(edit), &|url, toolchain, prefix, download_cfg, temp_cfg| {
490+
setup(Some(edit), false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
481491
change_channel_date(url, "nightly", "2016-02-01");
482492
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
483493
assert!(utils::path_exists(&prefix.path().join("bin/bonus")));
@@ -489,7 +499,7 @@ fn update_preserves_components_that_became_extensions() {
489499

490500
#[test]
491501
fn update_makes_no_changes_for_identical_manifest() {
492-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
502+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
493503
let status = update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
494504
assert_eq!(status, UpdateStatus::Changed);
495505
let status = update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
@@ -499,7 +509,7 @@ fn update_makes_no_changes_for_identical_manifest() {
499509

500510
#[test]
501511
fn add_extensions_for_initial_install() {
502-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
512+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
503513
let ref adds = vec![
504514
Component {
505515
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -517,7 +527,7 @@ fn add_extensions_for_initial_install() {
517527

518528
#[test]
519529
fn add_extensions_for_same_manifest() {
520-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
530+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
521531
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
522532

523533
let ref adds = vec![
@@ -538,7 +548,7 @@ fn add_extensions_for_same_manifest() {
538548

539549
#[test]
540550
fn add_extensions_for_upgrade() {
541-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
551+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
542552
change_channel_date(url, "nightly", "2016-02-01");
543553

544554
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
@@ -564,7 +574,7 @@ fn add_extensions_for_upgrade() {
564574
#[test]
565575
#[should_panic]
566576
fn add_extension_not_in_manifest() {
567-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
577+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
568578
let ref adds = vec![
569579
Component {
570580
pkg: "rust-bogus".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -578,7 +588,7 @@ fn add_extension_not_in_manifest() {
578588
#[test]
579589
#[should_panic]
580590
fn add_extension_that_is_required_component() {
581-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
591+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
582592
let ref adds = vec![
583593
Component {
584594
pkg: "rustc".to_string(), target: Some(TargetTriple::from_str("x86_64-apple-darwin"))
@@ -601,7 +611,7 @@ fn add_extensions_for_same_manifest_when_extension_already_installed() {
601611

602612
#[test]
603613
fn add_extensions_does_not_remove_other_components() {
604-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
614+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
605615
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
606616

607617
let ref adds = vec![
@@ -620,7 +630,7 @@ fn add_extensions_does_not_remove_other_components() {
620630
#[test]
621631
#[should_panic]
622632
fn remove_extensions_for_initial_install() {
623-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
633+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
624634
let ref removes = vec![
625635
Component {
626636
pkg: "rustc".to_string(), target: Some(TargetTriple::from_str("x86_64-apple-darwin"))
@@ -633,7 +643,7 @@ fn remove_extensions_for_initial_install() {
633643

634644
#[test]
635645
fn remove_extensions_for_same_manifest() {
636-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
646+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
637647
let ref adds = vec![
638648
Component {
639649
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -660,7 +670,7 @@ fn remove_extensions_for_same_manifest() {
660670

661671
#[test]
662672
fn remove_extensions_for_upgrade() {
663-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
673+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
664674
change_channel_date(url, "nightly", "2016-02-01");
665675

666676
let ref adds = vec![
@@ -692,7 +702,7 @@ fn remove_extensions_for_upgrade() {
692702
#[test]
693703
#[should_panic]
694704
fn remove_extension_not_in_manifest() {
695-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
705+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
696706
change_channel_date(url, "nightly", "2016-02-01");
697707

698708
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
@@ -724,7 +734,7 @@ fn remove_extension_not_in_manifest_but_is_already_installed() {
724734
});
725735
}
726736
};
727-
setup(Some(edit), &|url, toolchain, prefix, download_cfg, temp_cfg| {
737+
setup(Some(edit), false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
728738
change_channel_date(url, "nightly", "2016-02-01");
729739

730740
let ref adds = vec![
@@ -749,7 +759,7 @@ fn remove_extension_not_in_manifest_but_is_already_installed() {
749759
#[test]
750760
#[should_panic]
751761
fn remove_extension_that_is_required_component() {
752-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
762+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
753763
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
754764

755765
let ref removes = vec![
@@ -765,7 +775,7 @@ fn remove_extension_that_is_required_component() {
765775
#[test]
766776
#[should_panic]
767777
fn remove_extension_not_installed() {
768-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
778+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
769779
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
770780

771781
let ref removes = vec![
@@ -785,7 +795,7 @@ fn remove_extensions_for_same_manifest_does_not_reinstall_other_components() {
785795

786796
#[test]
787797
fn remove_extensions_does_not_remove_other_components() {
788-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
798+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
789799
let ref adds = vec![
790800
Component {
791801
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-apple-darwin"))
@@ -808,7 +818,7 @@ fn remove_extensions_does_not_remove_other_components() {
808818

809819
#[test]
810820
fn add_and_remove_for_upgrade() {
811-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
821+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
812822
change_channel_date(url, "nightly", "2016-02-01");
813823

814824
let ref adds = vec![
@@ -842,7 +852,7 @@ fn add_and_remove_for_upgrade() {
842852

843853
#[test]
844854
fn add_and_remove() {
845-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
855+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
846856
let ref adds = vec![
847857
Component {
848858
pkg: "rust-std".to_string(), target: Some(TargetTriple::from_str("i686-unknown-linux-gnu"))
@@ -873,7 +883,7 @@ fn add_and_remove() {
873883
#[test]
874884
#[should_panic]
875885
fn add_and_remove_same_component() {
876-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
886+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
877887
update_from_dist(url, toolchain, prefix, &[], &[], download_cfg, temp_cfg).unwrap();
878888

879889
let ref adds = vec![
@@ -894,7 +904,7 @@ fn add_and_remove_same_component() {
894904

895905
#[test]
896906
fn bad_component_hash() {
897-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
907+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
898908
let path = url.to_file_path().unwrap();
899909
let path = path.join("dist/2016-02-02/rustc-nightly-x86_64-apple-darwin.tar.gz");
900910
utils_raw::write_file(&path, "bogus").unwrap();
@@ -910,7 +920,7 @@ fn bad_component_hash() {
910920

911921
#[test]
912922
fn unable_to_download_component() {
913-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
923+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
914924
let path = url.to_file_path().unwrap();
915925
let path = path.join("dist/2016-02-02/rustc-nightly-x86_64-apple-darwin.tar.gz");
916926
fs::remove_file(&path).unwrap();
@@ -937,7 +947,7 @@ fn allow_installation(prefix: &InstallPrefix) {
937947

938948
#[test]
939949
fn reuse_downloaded_file() {
940-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
950+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
941951

942952
prevent_installation(prefix);
943953

@@ -967,7 +977,7 @@ fn reuse_downloaded_file() {
967977

968978
#[test]
969979
fn checks_files_hashes_before_reuse() {
970-
setup(None, &|url, toolchain, prefix, download_cfg, temp_cfg| {
980+
setup(None, false, &|url, toolchain, prefix, download_cfg, temp_cfg| {
971981

972982
let path = url.to_file_path().unwrap();
973983
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)