From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/tests/test_builtins.cmd | 41 ++++++++++++++++++++++++ programs/cmd/tests/test_builtins.cmd.exp | 30 +++++++++++++++++ 2 files changed, 71 insertions(+)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index b43848575fc..66d5e894662 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -468,6 +468,35 @@ call :setError 666 & ((for %%i in () do call :setError 33) &&echo SUCCESS !error call :setError 666 & ((for %%i in (a) do call :setError 0) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) call :setError 666 & ((for %%i in (a) do call :setError 33) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!)
+echo --- success/failure for external command +mkdir foo & cd foo +call :setError 666 & (I\dont\exist.exe &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & I\dont\exist.exe & echo ERRORLEVEL !errorlevel! +call :setError 666 & (Idontexist.exe &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & Idontexist.exe & echo ERRORLEVEL !errorlevel! +call :setError 666 & (cmd.exe /c "echo foo & exit /b 0" &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (cmd.exe /c "echo foo & exit /b 1024" &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +cd .. && rd /q /s foo +echo --- success/failure for CALL command +mkdir foo & cd foo +echo exit /b %%1 > foobar.bat +rem call :setError 666 & (call I\dont\exist.exe &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem terminates batch exec on native... +call :setError 666 & (call Idontexist.exe &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (call .\foobar.bat 0 &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (call .\foobar.bat 1024 &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (call cmd.exe /c "echo foo & exit /b 0" &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (call cmd.exe /c "echo foo & exit /b 1025" &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (call rmdir foobar.dir &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +cd .. && rd /q /s foo +echo --- success/failure for START command +call :setError 666 & (start "" /foobar >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem call :setError 666 & (start /B I\dont\exist.exe &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem can't run this test, generates a nice popup under windows +call :setError 666 & (start "" /B /WAIT cmd.exe /c "echo foo & exit /b 1024" &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem A call :setError 666 & (start "" /B cmd.exe /c "(choice /C:YN /T:3 /D:Y > NUL) & exit /b 1024" &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem can't do on Wine until /T is properly handled in CHOICE +rem SUCCESS 666 echo --- success/failure for TYPE command mkdir foo & cd foo echo a > fileA @@ -591,6 +620,18 @@ call :setError 666 & rmdir abc & echo ERRORLEVEL !errorlevel! call :setError 666 & rmdir @:\cba\abc & echo ERRORLEVEL !errorlevel! cd .. && rd /q /s foo
+echo --- success/failure for MKLINK command +mkdir foo & cd foo +call :setError 666 & (mklink &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (mklink /h foo &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (mklink /h foo foo &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (mklink /z foo foo &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +echo bar > foo +call :setError 666 & (mklink /h foo foo &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (mklink /h bar foo >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (mklink /h bar foo &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +cd .. && rd /q /s foo + echo --- success/failure for SETLOCAL/ENDLOCAL commands call :setError 666 & (setlocal foobar &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) call :setError 666 & (setlocal &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 4b162af9a8e..ed0e7d8d1e3 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -465,6 +465,28 @@ SUCCESS 666 SUCCESS 666 SUCCESS 0 FAILURE 33 +--- success/failure for external command +@todo_wine@FAILURE 1 +@todo_wine@ERRORLEVEL 3 +@todo_wine@FAILURE 1 +ERRORLEVEL 9009 +foo@space@ +SUCCESS 0 +foo@space@ +FAILURE 1024 +--- success/failure for CALL command +FAILURE 1 +SUCCESS 0 +FAILURE 1024 +foo@space@ +SUCCESS 0 +foo@space@ +FAILURE 1025 +@todo_wine@FAILURE 2 +--- success/failure for START command +@todo_wine@FAILURE 1 +foo@space@ +SUCCESS 1024 --- success/failure for TYPE command FAILURE 1 SUCCESS 0 @@ -535,6 +557,14 @@ ERRORLEVEL 666 ERRORLEVEL 666 ERRORLEVEL 666 ERRORLEVEL 666 +--- success/failure for MKLINK command +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@SUCCESS 0 +@todo_wine@FAILURE 1 --- success/failure for SETLOCAL/ENDLOCAL commands FAILURE 1 SUCCESS 0