cmd/tests: Add setlocal/endlocal tests.

This commit is contained in:
Frédéric Delanoy 2011-08-04 11:50:47 +02:00 committed by Alexandre Julliard
parent 8d328ff810
commit 920bdcc4b8
2 changed files with 58 additions and 0 deletions

View File

@ -650,6 +650,48 @@ call dir /b
cd ..
rd /s/q foobar
echo ------------ Testing setlocal/endlocal ------------
call :setError 0
rem Note: setlocal EnableDelayedExtension already tested in the variable delayed expansion test section
mkdir foobar & cd foobar
echo ...enable/disable extensions
setlocal DisableEXTensions
echo ErrLev: %ErrorLevel%
endlocal
echo ErrLev: %ErrorLevel%
echo @echo off> tmp.cmd
echo echo ErrLev: %%ErrorLevel%%>> tmp.cmd
rem Enabled by default
cmd /C tmp.cmd
cmd /E:OfF /C tmp.cmd
cmd /e:oN /C tmp.cmd
rem FIXME: creating file before setting envvar value to prevent parsing-time evaluation (due to EnableDelayedExpansion not being implemented/available yet)
echo ...setlocal with corresponding endlocal
echo @echo off> test.cmd
echo echo %%VAR%%>> test.cmd
echo setlocal>> test.cmd
echo set VAR=localval>> test.cmd
echo echo %%VAR%%>> test.cmd
echo endlocal>> test.cmd
echo echo %%VAR%%>> test.cmd
set VAR=globalval
call test.cmd
echo %VAR%
set VAR=
echo ...setlocal with no corresponding endlocal
echo @echo off> test.cmd
echo echo %%VAR%%>> test.cmd
echo setlocal>> test.cmd
echo set VAR=localval>> test.cmd
echo echo %%VAR%%>> test.cmd
set VAR=globalval
call test.cmd
echo %VAR%
set VAR=
cd ..
rd /q/s foobar
echo -----------Testing Errorlevel-----------
rem WARNING: Do *not* add tests using ErrorLevel after this section
should_not_exist 2> nul > nul

View File

@ -331,6 +331,22 @@ foo ''
@todo_wine@1
@todo_wine@1
non-builtin dir
------------ Testing setlocal/endlocal ------------
...enable/disable extensions
@todo_wine@ErrLev:@space@
ErrLev: 0
ErrLev: 0
@todo_wine@ErrLev:@space@@or_broken@ErrLev: 0
ErrLev: 0
...setlocal with corresponding endlocal
globalval
localval
globalval
globalval
...setlocal with no corresponding endlocal
globalval
localval
@todo_wine@globalval
-----------Testing Errorlevel-----------
9009
1