@@ -144,6 +144,45 @@ export PATH="$HOME/apple/bin"
144
144
} ) ;
145
145
}
146
146
147
+ #[ test]
148
+ fn install_with_zdotdir_from_calling_zsh ( ) {
149
+ // This test requires that zsh is callable.
150
+ if std:: process:: Command :: new ( "zsh" )
151
+ . arg ( "-c" )
152
+ . arg ( "true" )
153
+ . status ( )
154
+ . is_err ( )
155
+ {
156
+ return ;
157
+ }
158
+ clitools:: test ( Scenario :: Empty , & |config| {
159
+ let zdotdir = tempfile:: Builder :: new ( )
160
+ . prefix ( "zdotdir" )
161
+ . tempdir ( )
162
+ . unwrap ( ) ;
163
+ let rc = zdotdir. path ( ) . join ( ".zshenv" ) ;
164
+ raw:: write_file ( & rc, FAKE_RC ) . unwrap ( ) ;
165
+
166
+ // If $SHELL doesn't include "zsh", Zsh::zdotdir() will call zsh to obtain $ZDOTDIR.
167
+ // ZDOTDIR could be set directly in the environment, but having ~/.zshenv set
168
+ // ZDOTDIR is a normal setup, and ensures that the value came from calling zsh.
169
+ let home_zshenv = config. homedir . join ( ".zshenv" ) ;
170
+ let export_zdotdir = format ! (
171
+ "export ZDOTDIR=\" {}\" \n " ,
172
+ zdotdir. path( ) . as_os_str( ) . to_str( ) . unwrap( )
173
+ ) ;
174
+ raw:: write_file ( & home_zshenv, & export_zdotdir) . unwrap ( ) ;
175
+
176
+ let mut cmd = clitools:: cmd ( config, "rustup-init" , & INIT_NONE [ 1 ..] ) ;
177
+ cmd. env ( "SHELL" , "/bin/sh" ) ;
178
+ assert ! ( cmd. output( ) . unwrap( ) . status. success( ) ) ;
179
+
180
+ let new_rc = fs:: read_to_string ( & rc) . unwrap ( ) ;
181
+ let expected = FAKE_RC . to_owned ( ) + & source ( config. cargodir . display ( ) , POSIX_SH ) ;
182
+ assert_eq ! ( new_rc, expected) ;
183
+ } ) ;
184
+ }
185
+
147
186
#[ test]
148
187
fn install_adds_path_to_rc_just_once ( ) {
149
188
clitools:: test ( Scenario :: Empty , & |config| {
0 commit comments