From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/cmd/tests/batch.c | 10 ++++++++++ programs/cmd/tests/test_builtins.cmd | 24 ++++++++++++++++++++++++ programs/cmd/tests/test_builtins.cmd.exp | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+)
diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c index ade6587be81..d44d2d33dec 100644 --- a/programs/cmd/tests/batch.c +++ b/programs/cmd/tests/batch.c @@ -167,6 +167,7 @@ static const char *compare_line(const char *out_line, const char *out_end, const static const char space_cmd[] = {'@','s','p','a','c','e','@'}; static const char spaces_cmd[] = {'@','s','p','a','c','e','s','@'}; static const char tab_cmd[] = {'@','t','a','b','@'}; + static const char formfeed_cmd[] = {'@','f','o','r','m', 'f', 'e', 'e', 'd', '@'}; static const char or_broken_cmd[] = {'@','o','r','_','b','r','o','k','e','n','@'};
while(exp_ptr < exp_end) { @@ -242,6 +243,15 @@ static const char *compare_line(const char *out_line, const char *out_end, const } else { err = out_end; } + }else if(exp_ptr+sizeof(formfeed_cmd) <= exp_end + && !memcmp(exp_ptr, formfeed_cmd, sizeof(formfeed_cmd))) { + exp_ptr += sizeof(formfeed_cmd); + if(out_ptr < out_end && *out_ptr == '\f') { + out_ptr++; + continue; + } else { + err = out_end; + } }else if(exp_ptr+sizeof(or_broken_cmd) <= exp_end && !memcmp(exp_ptr, or_broken_cmd, sizeof(or_broken_cmd))) { if(out_ptr == out_end) diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 2bda4ad68ff..b43848575fc 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -669,6 +669,30 @@ call :setError 666 & help ACommandThatLikelyDoesntExist >NUL &&echo SUCCESS !err echo --- success/failure for PROMPT command call :setError 666 & prompt >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel! rem doesn't seem to set errors either on invalid $ escapes, nor qualifiers + +echo --- success/failure for CLS command +call :setError 666 & (cls &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (cls foobar &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (cls /X &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +echo --- success/failure for COLOR command +call :setError 666 & (color fc < NUL > NUL 2>&1 &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem TODO: color is also hard to test: it requires fd 1 to be bound to a console, so we can't redirect its output +echo --- success/failure for TITLE command +call :setError 666 & (title a new title &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (title &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +echo --- success/failure for CHOICE command +call :setError 666 & (choice <NUL >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (choice /c <NUL >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & ((echo A | choice /C:BA) >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (choice /C:BA <NUL >NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem syntax errors in command return INVALID_FUNCTION, need to find a test for returning 255 +echo --- success/failure for MORE command +call :setError 666 & (more NUL &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (more I\dont\exist.txt > NUL 2>&1 &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +call :setError 666 & (echo foo | more &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +echo --- success/failure for PAUSE command +call :setError 666 & (pause < NUL > NUL 2>&1 &&echo SUCCESS !errorlevel!||echo FAILURE !errorlevel!) +rem TODO: pause is harder to test when fd 1 is a console handle as we don't control output echo --- setlocal DisableDelayedExpansion echo ------------ Testing 'set' ------------ diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index de82728369a..3daf9f1b3db 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -598,6 +598,28 @@ FAILURE 1 SUCCESS 0 --- success/failure for PROMPT command SUCCESS 0 +--- success/failure for CLS command +@todo_wine@@formfeed@SUCCESS 666 +@todo_wine@@formfeed@SUCCESS 666 +@todo_wine@FAILURE 1 +--- success/failure for COLOR command +@todo_wine@FAILURE 1 +--- success/failure for TITLE command +SUCCESS 666 +SUCCESS 666 +--- success/failure for CHOICE command +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 1 +@todo_wine@FAILURE 2 +@todo_wine@FAILURE 1 +@todo_wine@--- success/failure for MORE command +SUCCESS 0 +@todo_wine@SUCCESS 0 +foo@space@ +@todo_wine@ +@todo_wine@SUCCESS 0 +@todo_wine@--- success/failure for PAUSE command +@todo_wine@FAILURE 1 --- ------------ Testing 'set' ------------ 1