@@ -159,11 +159,14 @@ fn test_csm_env_activate_no_hook() -> Result<(), Error> {
159159}
160160
161161/// Activate an environment and call something in it, using bash.
162+ /// Then deactivate it and ensure that thing was removed from PATH.
162163#[ cfg( feature = "__test_bash" ) ]
163164#[ test]
164- fn csm_env_activate_bash ( ) -> Result < ( ) , Error > {
165+ fn csm_env_activate_deactivate_bash ( ) -> Result < ( ) , Error > {
165166 let mut csm = common:: Csm :: new ( ) ?;
166167 let _ = csm_env_create ( & mut csm, "csm_env_activate_bash" ) ;
168+
169+ // activate
167170 csm. ext_command ( which ( "bash" ) ?)
168171 . arg ( "-c" )
169172 . arg (
@@ -174,15 +177,31 @@ fn csm_env_activate_bash() -> Result<(), Error> {
174177 . assert ( )
175178 . code ( 251 )
176179 . stdout ( predicate:: str:: is_match ( "^Robot Framework" ) ?) ;
180+
181+ // deactivate
182+ csm. ext_command ( which ( "bash" ) ?)
183+ . arg ( "-c" )
184+ . arg (
185+ "eval \" $(csm init bash --code)\" &&\
186+ csm env activate -n csm_env_activate_bash &&\
187+ csm env deactivate &&\
188+ robot --version",
189+ )
190+ . assert ( )
191+ . failure ( )
192+ . stderr ( predicate:: str:: contains ( "command not found" ) ) ;
177193 Ok ( ( ) )
178194}
179195
180196/// Activate an environment and call something in it, using powershell.
197+ /// Then deactivate it and ensure that thing was removed from PATH.
181198#[ cfg( feature = "__test_powershell" ) ]
182199#[ test]
183- fn csm_env_activate_powershell ( ) -> Result < ( ) , Error > {
200+ fn csm_env_activate_deactivate_powershell ( ) -> Result < ( ) , Error > {
184201 let mut csm = common:: Csm :: new ( ) ?;
185202 let _ = csm_env_create ( & mut csm, "csm_env_activate_bash" ) ;
203+
204+ // activate
186205 csm. ext_command ( which ( "pwsh" ) ?)
187206 . arg ( "-c" )
188207 . arg ( format ! (
@@ -192,5 +211,20 @@ fn csm_env_activate_powershell() -> Result<(), Error> {
192211 ) )
193212 . assert ( )
194213 . stdout ( predicate:: str:: is_match ( "^Robot Framework" ) ?) ;
214+
215+ // deactivate
216+ csm. ext_command ( which ( "pwsh" ) ?)
217+ . arg ( "-c" )
218+ . arg ( format ! (
219+ "csm init powershell --code | Out-String | Invoke-Expression &&\
220+ csm env activate -n csm_env_activate_bash &&\
221+ csm env deactivate &&\
222+ robot --version",
223+ ) )
224+ . assert ( )
225+ . failure ( )
226+ . stderr ( predicate:: str:: contains (
227+ "not recognized as a name of a cmdlet" ,
228+ ) ) ;
195229 Ok ( ( ) )
196230}
0 commit comments