@@ -70,6 +70,31 @@ pub fn update_setup(f: &dyn Fn(&Config, &Path)) {
70
70
} ) ;
71
71
}
72
72
73
+ /// Empty dist server, rustup installed with no toolchain
74
+ fn setup_empty_installed ( f : & dyn Fn ( & Config ) ) {
75
+ clitools:: setup ( Scenario :: Empty , & |config| {
76
+ expect_ok (
77
+ config,
78
+ & [
79
+ "rustup-init" ,
80
+ "-y" ,
81
+ "--no-modify-path" ,
82
+ "--default-toolchain" ,
83
+ "none" ,
84
+ ] ,
85
+ ) ;
86
+ f ( config) ;
87
+ } )
88
+ }
89
+
90
+ /// SimpleV3 dist server, rustup installed with default toolchain
91
+ fn setup_installed ( f : & dyn Fn ( & Config ) ) {
92
+ clitools:: setup ( Scenario :: SimpleV2 , & |config| {
93
+ expect_ok ( config, & [ "rustup-init" , "-y" , "--no-modify-path" ] ) ;
94
+ f ( config) ;
95
+ } )
96
+ }
97
+
73
98
fn output_release_file ( dist_dir : & Path , schema : & str , version : & str ) {
74
99
let contents = format ! (
75
100
r#"
@@ -179,17 +204,7 @@ fn install_creates_cargo_home() {
179
204
/// Functional test needed here - we need to do the full dance where we start
180
205
/// with rustup.exe and end up deleting that exe itself.
181
206
fn uninstall_deletes_bins ( ) {
182
- clitools:: setup ( Scenario :: Empty , & |config| {
183
- expect_ok (
184
- config,
185
- & [
186
- "rustup-init" ,
187
- "-y" ,
188
- "--no-modify-path" ,
189
- "--default-toolchain" ,
190
- "none" ,
191
- ] ,
192
- ) ;
207
+ setup_empty_installed ( & |config| {
193
208
// no-modify-path isn't needed here, as the test-dir-path isn't present
194
209
// in the registry, so the no-change code path will be triggered.
195
210
expect_ok ( config, & [ "rustup" , "self" , "uninstall" , "-y" ] ) ;
@@ -212,8 +227,7 @@ fn uninstall_deletes_bins() {
212
227
213
228
#[ test]
214
229
fn uninstall_works_if_some_bins_dont_exist ( ) {
215
- setup ( & |config| {
216
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
230
+ setup_empty_installed ( & |config| {
217
231
let rustup = config. cargodir . join ( & format ! ( "bin/rustup{}" , EXE_SUFFIX ) ) ;
218
232
let rustc = config. cargodir . join ( & format ! ( "bin/rustc{}" , EXE_SUFFIX ) ) ;
219
233
let rustdoc = config. cargodir . join ( & format ! ( "bin/rustdoc{}" , EXE_SUFFIX ) ) ;
@@ -239,36 +253,31 @@ fn uninstall_works_if_some_bins_dont_exist() {
239
253
240
254
#[ test]
241
255
fn uninstall_deletes_rustup_home ( ) {
242
- setup ( & |config| {
243
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
244
- expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
256
+ setup_empty_installed ( & |config| {
245
257
expect_ok ( config, & [ "rustup" , "self" , "uninstall" , "-y" ] ) ;
246
258
assert ! ( !config. rustupdir. has( "." ) ) ;
247
259
} ) ;
248
260
}
249
261
250
262
#[ test]
251
263
fn uninstall_works_if_rustup_home_doesnt_exist ( ) {
252
- setup ( & |config| {
253
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
264
+ setup_empty_installed ( & |config| {
254
265
config. rustupdir . remove ( ) . unwrap ( ) ;
255
266
expect_ok ( config, & [ "rustup" , "self" , "uninstall" , "-y" ] ) ;
256
267
} ) ;
257
268
}
258
269
259
270
#[ test]
260
271
fn uninstall_deletes_cargo_home ( ) {
261
- setup ( & |config| {
262
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
272
+ setup_empty_installed ( & |config| {
263
273
expect_ok ( config, & [ "rustup" , "self" , "uninstall" , "-y" ] ) ;
264
274
assert ! ( !config. cargodir. exists( ) ) ;
265
275
} ) ;
266
276
}
267
277
268
278
#[ test]
269
279
fn uninstall_fails_if_not_installed ( ) {
270
- setup ( & |config| {
271
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
280
+ setup_empty_installed ( & |config| {
272
281
let rustup = config. cargodir . join ( & format ! ( "bin/rustup{}" , EXE_SUFFIX ) ) ;
273
282
fs:: remove_file ( & rustup) . unwrap ( ) ;
274
283
expect_err (
@@ -285,8 +294,7 @@ fn uninstall_fails_if_not_installed() {
285
294
#[ test]
286
295
#[ cfg_attr( target_os = "macos" , ignore) ] // FIXME #1515
287
296
fn uninstall_self_delete_works ( ) {
288
- setup ( & |config| {
289
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
297
+ setup_empty_installed ( & |config| {
290
298
let rustup = config. cargodir . join ( & format ! ( "bin/rustup{}" , EXE_SUFFIX ) ) ;
291
299
let mut cmd = Command :: new ( rustup. clone ( ) ) ;
292
300
cmd. args ( & [ "self" , "uninstall" , "-y" ] ) ;
@@ -321,8 +329,7 @@ fn uninstall_doesnt_leave_gc_file() {
321
329
use std:: thread;
322
330
use std:: time:: Duration ;
323
331
324
- setup ( & |config| {
325
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
332
+ setup_empty_installed ( & |config| {
326
333
expect_ok ( config, & [ "rustup" , "self" , "uninstall" , "-y" ] ) ;
327
334
328
335
// The gc removal happens after rustup terminates. Give it a moment.
@@ -622,92 +629,115 @@ fn rustup_still_works_after_update() {
622
629
} ) ;
623
630
}
624
631
625
- // There's a race condition between the updater replacing
626
- // the rustup binary and tool hardlinks and subsequent
627
- // invocations of rustup and rustc (on windows).
628
- #[ test]
629
- #[ ignore]
630
- fn update_stress_test ( ) { }
631
-
632
632
// The installer used to be called rustup-setup. For compatibility it
633
633
// still needs to work in that mode.
634
634
#[ test]
635
- #[ cfg( not( windows) ) ]
636
635
fn as_rustup_setup ( ) {
637
- update_setup ( & |config, _ | {
636
+ clitools :: setup ( Scenario :: Empty , & |config| {
638
637
let init = config. exedir . join ( format ! ( "rustup-init{}" , EXE_SUFFIX ) ) ;
639
638
let setup = config. exedir . join ( format ! ( "rustup-setup{}" , EXE_SUFFIX ) ) ;
640
639
fs:: copy ( & init, & setup) . unwrap ( ) ;
641
- expect_ok ( config, & [ "rustup-setup" , "-y" ] ) ;
640
+ expect_ok (
641
+ config,
642
+ & [
643
+ "rustup-setup" ,
644
+ "-y" ,
645
+ "--no-modify-path" ,
646
+ "--default-toolchain" ,
647
+ "none" ,
648
+ ] ,
649
+ ) ;
642
650
} ) ;
643
651
}
644
652
645
653
#[ test]
646
654
fn reinstall_exact ( ) {
647
- setup ( & |config| {
648
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
655
+ setup_empty_installed ( & |config| {
649
656
expect_stderr_ok (
650
657
config,
651
- & [ "rustup-init" , "-y" , "--no-update-default-toolchain" ] ,
658
+ & [
659
+ "rustup-init" ,
660
+ "-y" ,
661
+ "--no-update-default-toolchain" ,
662
+ "--no-modify-path" ,
663
+ ] ,
652
664
r"info: updating existing rustup installation - leaving toolchains alone" ,
653
665
) ;
654
666
} ) ;
655
667
}
656
668
657
669
#[ test]
658
670
fn reinstall_specifying_toolchain ( ) {
659
- setup ( & |config| {
660
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
671
+ setup_installed ( & |config| {
661
672
expect_stdout_ok (
662
673
config,
663
- & [ "rustup-init" , "-y" , "--default-toolchain=stable" ] ,
674
+ & [
675
+ "rustup-init" ,
676
+ "-y" ,
677
+ "--default-toolchain=stable" ,
678
+ "--no-modify-path" ,
679
+ ] ,
664
680
for_host ! ( r"stable-{0} unchanged - 1.1.0" ) ,
665
681
) ;
666
682
} ) ;
667
683
}
668
684
669
685
#[ test]
670
686
fn reinstall_specifying_component ( ) {
671
- setup ( & |config| {
672
- expect_ok ( config, & [ "rustup-init " , "-y " , "--component= rls" ] ) ;
687
+ setup_installed ( & |config| {
688
+ expect_ok ( config, & [ "rustup" , "component " , "add" , " rls"] ) ;
673
689
expect_stdout_ok (
674
690
config,
675
- & [ "rustup-init" , "-y" , "--default-toolchain=stable" ] ,
691
+ & [
692
+ "rustup-init" ,
693
+ "-y" ,
694
+ "--default-toolchain=stable" ,
695
+ "--no-modify-path" ,
696
+ ] ,
676
697
for_host ! ( r"stable-{0} unchanged - 1.1.0" ) ,
677
698
) ;
678
699
} ) ;
679
700
}
680
701
681
702
#[ test]
682
703
fn reinstall_specifying_different_toolchain ( ) {
683
- setup ( & |config| {
684
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
704
+ clitools:: setup ( Scenario :: SimpleV2 , & |config| {
685
705
expect_stderr_ok (
686
706
config,
687
- & [ "rustup-init" , "-y" , "--default-toolchain=nightly" ] ,
707
+ & [
708
+ "rustup-init" ,
709
+ "-y" ,
710
+ "--default-toolchain=nightly" ,
711
+ "--no-modify-path" ,
712
+ ] ,
688
713
for_host ! ( r"info: default toolchain set to 'nightly-{0}'" ) ,
689
714
) ;
690
715
} ) ;
691
716
}
692
717
693
718
#[ test]
694
719
fn install_sets_up_stable_unless_a_different_default_is_requested ( ) {
695
- setup ( & |config| {
720
+ clitools :: setup ( Scenario :: SimpleV2 , & |config| {
696
721
expect_ok (
697
722
config,
698
- & [ "rustup-init" , "-y" , "--default-toolchain" , "nightly" ] ,
723
+ & [
724
+ "rustup-init" ,
725
+ "-y" ,
726
+ "--default-toolchain" ,
727
+ "nightly" ,
728
+ "--no-modify-path" ,
729
+ ] ,
699
730
) ;
700
731
expect_stdout_ok ( config, & [ "rustc" , "--version" ] , "hash-nightly-2" ) ;
701
732
} ) ;
702
733
}
703
734
704
735
#[ test]
705
736
fn install_sets_up_stable_unless_there_is_already_a_default ( ) {
706
- setup ( & |config| {
707
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
737
+ setup_installed ( & |config| {
708
738
expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
709
739
expect_ok ( config, & [ "rustup" , "toolchain" , "remove" , "stable" ] ) ;
710
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
740
+ expect_ok ( config, & [ "rustup-init" , "-y" , "--no-modify-path" ] ) ;
711
741
expect_stdout_ok ( config, & [ "rustc" , "--version" ] , "hash-nightly-2" ) ;
712
742
expect_err (
713
743
config,
@@ -719,10 +749,10 @@ fn install_sets_up_stable_unless_there_is_already_a_default() {
719
749
720
750
#[ test]
721
751
fn readline_no_stdin ( ) {
722
- setup ( & |config| {
752
+ clitools :: setup ( Scenario :: SimpleV2 , & |config| {
723
753
expect_err (
724
754
config,
725
- & [ "rustup-init" ] ,
755
+ & [ "rustup-init" , "--no-modify-path" ] ,
726
756
"unable to read from stdin for confirmation" ,
727
757
) ;
728
758
} ) ;
@@ -732,43 +762,40 @@ fn readline_no_stdin() {
732
762
fn rustup_init_works_with_weird_names ( ) {
733
763
// Browsers often rename bins to e.g. rustup-init(2).exe.
734
764
735
- setup ( & |config| {
765
+ clitools :: setup ( Scenario :: SimpleV2 , & |config| {
736
766
let old = config. exedir . join ( & format ! ( "rustup-init{}" , EXE_SUFFIX ) ) ;
737
767
let new = config. exedir . join ( & format ! ( "rustup-init(2){}" , EXE_SUFFIX ) ) ;
738
768
utils:: rename_file ( "test" , & old, & new, & |_: Notification < ' _ > | { } ) . unwrap ( ) ;
739
- expect_ok ( config, & [ "rustup-init(2)" , "-y" ] ) ;
769
+ expect_ok ( config, & [ "rustup-init(2)" , "-y" , "--no-modify-path" ] ) ;
740
770
let rustup = config. cargodir . join ( & format ! ( "bin/rustup{}" , EXE_SUFFIX ) ) ;
741
771
assert ! ( rustup. exists( ) ) ;
742
772
} ) ;
743
773
}
744
774
745
- #[ test]
746
- #[ ignore] // untestable
747
- fn install_but_rustup_is_installed ( ) { }
748
-
749
- #[ test]
750
- #[ ignore] // untestable
751
- fn install_but_rustc_is_installed ( ) { }
752
-
753
775
#[ test]
754
776
fn install_but_rustup_sh_is_installed ( ) {
755
- setup ( & |config| {
777
+ clitools :: setup ( Scenario :: Empty , & |config| {
756
778
let rustup_dir = config. homedir . join ( ".rustup" ) ;
757
779
fs:: create_dir_all ( & rustup_dir) . unwrap ( ) ;
758
780
let version_file = rustup_dir. join ( "rustup-version" ) ;
759
781
raw:: write_file ( & version_file, "" ) . unwrap ( ) ;
760
782
expect_stderr_ok (
761
783
config,
762
- & [ "rustup-init" , "-y" ] ,
784
+ & [
785
+ "rustup-init" ,
786
+ "-y" ,
787
+ "--default-toolchain" ,
788
+ "none" ,
789
+ "--no-modify-path" ,
790
+ ] ,
763
791
"cannot install while rustup.sh is installed" ,
764
792
) ;
765
793
} ) ;
766
794
}
767
795
768
796
#[ test]
769
797
fn rls_proxy_set_up_after_install ( ) {
770
- setup ( & |config| {
771
- expect_ok ( config, & [ "rustup-init" , "-y" ] ) ;
798
+ setup_installed ( & |config| {
772
799
expect_err (
773
800
config,
774
801
& [ "rls" , "--version" ] ,
@@ -852,7 +879,7 @@ fn update_installs_clippy_cargo_and() {
852
879
853
880
#[ test]
854
881
fn install_with_components_and_targets ( ) {
855
- setup ( & |config| {
882
+ clitools :: setup ( Scenario :: SimpleV2 , & |config| {
856
883
expect_ok (
857
884
config,
858
885
& [
@@ -864,6 +891,7 @@ fn install_with_components_and_targets() {
864
891
"rls" ,
865
892
"-t" ,
866
893
clitools:: CROSS_ARCH1 ,
894
+ "--no-modify-path" ,
867
895
] ,
868
896
) ;
869
897
expect_stdout_ok (
0 commit comments