@@ -158,4 +158,64 @@ ls $TEMP
158158 println ! ( "{x:?}" ) ;
159159 assert ! ( !x. stdout. is_empty( ) ) ;
160160 }
161+
162+ #[ test]
163+ #[ cfg( windows) ]
164+ fn test_powershell ( ) {
165+ let out = run_powershell ( "ls" , true ) . unwrap ( ) ;
166+ assert ! ( !out. is_empty( ) ) ;
167+ println ! ( "output=`{out}`" ) ;
168+
169+ let uuid = run_powershell (
170+ r"(Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography).MachineGuid" ,
171+ true ,
172+ ) . unwrap ( ) ;
173+ assert ! ( !uuid. is_empty( ) ) ;
174+ println ! ( "11 uuid=`{uuid}`" ) ;
175+
176+ let val: String = hklm_open_subkey ( "SOFTWARE\\ Microsoft\\ Cryptography" )
177+ . unwrap ( )
178+ . get_value ( "MachineGuid" )
179+ . unwrap ( ) ;
180+ println ! ( "12 {val:?}" ) ;
181+ assert_eq ! ( uuid, val) ;
182+ }
183+
184+ #[ test]
185+ #[ cfg( unix) ]
186+ fn test_script ( ) {
187+ let x = run_script ( "ls" , true ) . unwrap ( ) ;
188+ println ! ( "{x}" ) ;
189+ assert_eq ! ( x. code, 0 ) ;
190+ assert ! ( x. stdout. len( ) > 10 ) ;
191+
192+ let x = run_script ( "zhandubalm" , true ) ;
193+ assert ! ( x. is_ok( ) , "{x:?}" ) ;
194+ let x = x. unwrap ( ) ;
195+ assert_eq ! ( x. code, 127 ) ; // command not found.
196+ assert ! ( x. stderr. len( ) > 1 ) ;
197+
198+ let x = run_script ( "which cargo" , true ) . unwrap ( ) ;
199+ println ! ( "{x}" ) ;
200+ assert_eq ! ( x. code, 0 ) ;
201+ assert ! ( x. stdout. len( ) > 1 ) ;
202+ }
203+
204+ #[ test]
205+ #[ cfg( windows) ]
206+ fn test_script ( ) {
207+ let x = run_script ( "dir" , true ) . unwrap ( ) ;
208+ println ! ( "{x}" ) ;
209+ assert_eq ! ( x. code, 0 ) ;
210+ assert ! ( x. stdout. len( ) > 10 ) ;
211+
212+ let x = run_script ( "zhandubalm" , true ) ;
213+ println ! ( "{x:?}" ) ;
214+ assert ! ( x. is_err( ) ) ;
215+
216+ let cmd = r"(Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography).MachineGuid" ;
217+ let x = run_script ( cmd, true ) . unwrap ( ) ;
218+ println ! ( "{x}" ) ;
219+ assert_eq ! ( x. code, 0 ) ;
220+ }
161221}
0 commit comments