@@ -59,18 +59,43 @@ export PATH="$HOME/apple/bin"
5959 assert ! ( cmd. output( ) . unwrap( ) . status. success( ) ) ;
6060 let mut rcs = files. iter ( ) ;
6161 let env = rcs. next ( ) . unwrap ( ) ;
62- let envfile = fs:: read_to_string ( & env) . unwrap ( ) ;
62+ let envfile = fs:: read_to_string ( env) . unwrap ( ) ;
6363 let ( _, envfile_export) = envfile. split_at ( envfile. find ( "export PATH" ) . unwrap_or ( 0 ) ) ;
6464 assert_eq ! ( & envfile_export[ ..DEFAULT_EXPORT . len( ) ] , DEFAULT_EXPORT ) ;
6565
6666 for rc in rcs {
6767 let expected = source ( "$HOME/.cargo" , POSIX_SH ) ;
68- let new_profile = fs:: read_to_string ( & rc) . unwrap ( ) ;
68+ let new_profile = fs:: read_to_string ( rc) . unwrap ( ) ;
6969 assert_eq ! ( new_profile, expected) ;
7070 }
7171 } ) ;
7272 }
7373
74+ #[ test]
75+ fn install_creates_necessary_fish_scripts_new ( ) {
76+ clitools:: setup ( Scenario :: Empty , & |config| {
77+ let mut cmd = clitools:: cmd ( config, "rustup-init" , & INIT_NONE [ 1 ..] ) ;
78+ let rcs: Vec < PathBuf > = [ ".cargo/env.fish" , ".config/fish/config.fish" ]
79+ . iter ( )
80+ . map ( |file| config. homedir . join ( file) )
81+ . collect ( ) ;
82+ for file in & rcs {
83+ assert ! ( !file. exists( ) ) ;
84+ }
85+ cmd. env_remove ( "CARGO_HOME" ) ;
86+ cmd. env ( "SHELL" , "fish" ) ;
87+ cmd. env ( "XDG_DATA_DIRS" , "" ) ; // Overwrite XDG as host shouldn't be affected by the test.
88+ assert ! ( cmd. output( ) . unwrap( ) . status. success( ) ) ;
89+ let expected = include_str ! ( "../src/cli/self_update/env.fish" )
90+ . replace ( "{cargo_bin}" , "$HOME/.cargo/bin" ) ;
91+
92+ assert ! ( rcs
93+ . iter( )
94+ . filter_map( |rc| fs:: read_to_string( rc) . ok( ) ) // Read contents of files that exist
95+ . any( |rc_content| rc_content. contains( & expected) ) ) ;
96+ } )
97+ }
98+
7499 #[ test]
75100 fn install_updates_bash_rcs ( ) {
76101 clitools:: setup ( Scenario :: Empty , & |config| {
@@ -86,7 +111,7 @@ export PATH="$HOME/apple/bin"
86111
87112 let expected = FAKE_RC . to_owned ( ) + & source ( config. cargodir . display ( ) , POSIX_SH ) ;
88113 for rc in & rcs {
89- let new_rc = fs:: read_to_string ( & rc) . unwrap ( ) ;
114+ let new_rc = fs:: read_to_string ( rc) . unwrap ( ) ;
90115 assert_eq ! ( new_rc, expected) ;
91116 }
92117 } )
@@ -191,9 +216,9 @@ export PATH="$HOME/apple/bin"
191216
192217 expect_ok ( config, & INIT_NONE ) ;
193218
194- let new1 = fs:: read_to_string ( & path1) . unwrap ( ) ;
219+ let new1 = fs:: read_to_string ( path1) . unwrap ( ) ;
195220 assert_eq ! ( new1, expected) ;
196- let new2 = fs:: read_to_string ( & path2) . unwrap ( ) ;
221+ let new2 = fs:: read_to_string ( path2) . unwrap ( ) ;
197222 assert_eq ! ( new2, expected) ;
198223 }
199224 } ) ;
@@ -221,7 +246,7 @@ export PATH="$HOME/apple/bin"
221246 expect_ok ( config, & [ "rustup" , "self" , "uninstall" , "-y" ] ) ;
222247
223248 for rc in & rcs {
224- let new_rc = fs:: read_to_string ( & rc) . unwrap ( ) ;
249+ let new_rc = fs:: read_to_string ( rc) . unwrap ( ) ;
225250 assert_eq ! ( new_rc, FAKE_RC ) ;
226251 }
227252 } )
@@ -255,11 +280,11 @@ export PATH="$HOME/apple/bin"
255280 assert ! ( cmd. output( ) . unwrap( ) . status. success( ) ) ;
256281 let fixed_rc = FAKE_RC . to_owned ( ) + & source ( "$HOME/.cargo" , POSIX_SH ) ;
257282 for rc in & rcs {
258- let new_rc = fs:: read_to_string ( & rc) . unwrap ( ) ;
283+ let new_rc = fs:: read_to_string ( rc) . unwrap ( ) ;
259284 assert_eq ! ( new_rc, fixed_rc) ;
260285 }
261286 for rc in & zprofiles {
262- let new_rc = fs:: read_to_string ( & rc) . unwrap ( ) ;
287+ let new_rc = fs:: read_to_string ( rc) . unwrap ( ) ;
263288 assert_eq ! ( new_rc, FAKE_RC ) ;
264289 }
265290 } )
@@ -291,14 +316,14 @@ export PATH="$HOME/apple/bin"
291316 raw:: write_file ( rc, & old_rc) . unwrap ( ) ;
292317 }
293318
294- let mut cmd = clitools:: cmd ( config, "rustup" , & [ "self" , "uninstall" , "-y" ] ) ;
319+ let mut cmd = clitools:: cmd ( config, "rustup" , [ "self" , "uninstall" , "-y" ] ) ;
295320 cmd. env ( "SHELL" , "zsh" ) ;
296321 cmd. env ( "ZDOTDIR" , zdotdir. path ( ) ) ;
297322 cmd. env_remove ( "CARGO_HOME" ) ;
298323 assert ! ( cmd. output( ) . unwrap( ) . status. success( ) ) ;
299324
300325 for rc in & rcs {
301- let new_rc = fs:: read_to_string ( & rc) . unwrap ( ) ;
326+ let new_rc = fs:: read_to_string ( rc) . unwrap ( ) ;
302327 // It's not ideal, but it's OK, if we leave whitespace.
303328 assert_eq ! ( new_rc, FAKE_RC ) ;
304329 }
@@ -324,7 +349,7 @@ export PATH="$HOME/apple/bin"
324349 let expected = format ! ( "{}. \" $HOME/.cargo/env\" \n " , FAKE_RC ) ;
325350 assert_eq ! ( new_profile, expected) ;
326351
327- let mut cmd = clitools:: cmd ( config, "rustup" , & [ "self" , "uninstall" , "-y" ] ) ;
352+ let mut cmd = clitools:: cmd ( config, "rustup" , [ "self" , "uninstall" , "-y" ] ) ;
328353 cmd. env_remove ( "CARGO_HOME" ) ;
329354 assert ! ( cmd. output( ) . unwrap( ) . status. success( ) ) ;
330355
0 commit comments