@@ -156,7 +156,9 @@ export PATH="$HOME/apple/bin"
156156 let profile = config. homedir . join ( ".profile" ) ;
157157 let fake_rc_modified = FAKE_RC . strip_suffix ( '\n' ) . expect ( "Should end in a newline" ) ;
158158 raw:: write_file ( & profile, fake_rc_modified) . unwrap ( ) ;
159+ // Run once to to add the configuration
159160 expect_ok ( config, & INIT_NONE ) ;
161+ // Run twice to test that the process is idempotent
160162 expect_ok ( config, & INIT_NONE ) ;
161163
162164 let new_profile = fs:: read_to_string ( & profile) . unwrap ( ) ;
@@ -165,6 +167,32 @@ export PATH="$HOME/apple/bin"
165167 } ) ;
166168 }
167169
170+
171+ #[ test]
172+ fn install_adds_path_to_multiple_rc_files ( ) {
173+ clitools:: setup ( Scenario :: Empty , & |config| {
174+ // Two RC files that are both from the same shell
175+ let bash_profile = config. homedir . join ( ".bash_profile" ) ;
176+ let bashrc = config. homedir . join ( ".bashrc" ) ;
177+
178+ let expected = FAKE_RC . to_owned ( ) + & source ( config. cargodir . display ( ) , POSIX_SH ) ;
179+
180+ // The order that the two files are processed isn't known, so test both orders
181+ for [ path1, path2] in & [ [ & bash_profile, & bashrc] , [ & bashrc, & bash_profile] ] {
182+
183+ raw:: write_file ( & path1, & expected) . unwrap ( ) ;
184+ raw:: write_file ( & path2, FAKE_RC ) . unwrap ( ) ;
185+
186+ expect_ok ( config, & INIT_NONE ) ;
187+
188+ let new1 = fs:: read_to_string ( & path1) . unwrap ( ) ;
189+ assert_eq ! ( new1, expected) ;
190+ let new2 = fs:: read_to_string ( & path2) . unwrap ( ) ;
191+ assert_eq ! ( new2, expected) ;
192+ }
193+ } ) ;
194+ }
195+
168196 #[ test]
169197 fn uninstall_removes_source_from_rcs ( ) {
170198 clitools:: setup ( Scenario :: Empty , & |config| {
0 commit comments