Module: wine Branch: master Commit: 7b1d6412b52cd12c901f2e3f20a5b186b1f06686 URL: https://gitlab.winehq.org/wine/wine/-/commit/7b1d6412b52cd12c901f2e3f20a5b18...
Author: Eric Pouech epouech@codeweavers.com Date: Sun Jul 14 09:23:10 2024 +0200
cmd: Add success/failure tests for pipes and drive change.
Signed-off-by: Eric Pouech epouech@codeweavers.com
---
programs/cmd/tests/test_builtins.cmd | 22 ++++++++++++++++++++-- programs/cmd/tests/test_builtins.cmd.exp | 21 +++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index c67fc84988a..945b68e25a9 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -467,12 +467,13 @@ if 1==0 (echo q1) else echo q2&echo q3 echo ------------- Testing internal commands return codes setlocal EnableDelayedExpansion
-echo --- call and IF/FOR blocks +echo --- success/failure for basics call :setError 0 &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel! call :setError 33 &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel! call :setError 666 & (echo foo &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) call :setError 666 & (echo foo >> h:\i\dont\exist\at\all.txt &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) call :setError 666 & echo foo >> h:\i\dont\exist\at\all.txt & echo ERRORLEVEL !errorlevel! +echo --- success/failure for IF/FOR blocks call :setError 666 & ((if 1==1 echo "">NUL) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) call :setError 666 & ((if 1==0 echo "">NUL) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) call :setError 666 & ((if 1==1 (call :setError 33)) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) @@ -481,7 +482,6 @@ call :setError 666 & ((for %%i in () do echo "") &&echo SUCCESS !errorlevel!||ec call :setError 666 & ((for %%i in () do call :setError 33) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) 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!) @@ -503,6 +503,18 @@ call :setError 666 & (call cmd.exe /c "echo foo & exit /b 0" &&echo SUCCESS !err 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 pipes +call :setError 666 & ((echo a | echo b) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & ((echo a | call :setError 34) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & ((call :setError 33 | echo a) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & ((echo a | rmdir I\dont\exist\at\all) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & ((rmdir I\dont\exist\at\all | echo a) &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem in a pipe, if LHS or RHS can't be started, the whole cmd is abandonned (not just the pipe!!) +echo ^( %%1 ^| %%2 ^) > foo.bat +echo echo AFTER %%ERRORLEVEL%% >> foo.bat +call :setError 666 & (cmd.exe /q /c "call foo.bat echo I\dont\exist.exe" &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (cmd.exe /q /c "call foo.bat I\dont\exist.exe echo" &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +erase /q foo.bat 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!) @@ -568,6 +580,12 @@ call :setError 666 & (erase i\dont\exist\at\all.txt &&echo SUCCESS !errorlevel!| call :setError 666 & (erase file* i\dont\exist\at\all.txt &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) cd .. && rd /q /s foo
+echo --- success/failure for change drive command +call :setError 666 & (c: &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (1: &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (call c: &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (call 1: &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) + echo --- success/failure for MKDIR,MD command mkdir foo & cd foo call :setError 666 & (mkdir &&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 84bcdcdf581..58b4dcfb00e 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -452,13 +452,14 @@ p2 q2 q3 ------------- Testing internal commands return codes ---- call and IF/FOR blocks +--- success/failure for basics SUCCESS 0 FAILURE 33 foo@space@ SUCCESS 666 FAILURE 1 ERRORLEVEL 666 +--- success/failure for IF/FOR blocks SUCCESS 666 SUCCESS 666 FAILURE 33 @@ -485,7 +486,18 @@ SUCCESS 0 foo@space@ FAILURE 1025 FAILURE 2 ---- success/failure for START command +--- success/failure for pipes +b +@todo_wine@SUCCESS 0 +@todo_wine@FAILURE 1 +a +@todo_wine@SUCCESS 0 +FAILURE 3 +a +@todo_wine@SUCCESS 0 +@todo_wine@FAILURE 255 +@todo_wine@FAILURE 255 +@todo_wine@--- success/failure for START command @todo_wine@FAILURE 1 foo@space@ SUCCESS 1024 @@ -521,6 +533,11 @@ FAILURE 1 SUCCESS 0 FAILURE 1 FAILURE 1 +--- success/failure for change drive command +@todo_wine@SUCCESS 666 +FAILURE 1 +@todo_wine@SUCCESS 0 +FAILURE 1 --- success/failure for MKDIR,MD command FAILURE 1 SUCCESS 0