[4/4] cmd/tests: Add setlocal/endlocal tests

Frédéric Delanoy frederic.delanoy at gmail.com
Thu Aug 4 04:50:47 CDT 2011


---
 programs/cmd/tests/test_builtins.cmd     |   42 ++++++++++++++++++++++++++++++
 programs/cmd/tests/test_builtins.cmd.exp |   16 +++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 2321e12..a27c833 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -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
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index c430883..c4f0d76 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -331,6 +331,22 @@ foo ''
 @todo_wine at 1
 @todo_wine at 1
 non-builtin dir
+------------ Testing setlocal/endlocal ------------
+...enable/disable extensions
+ at todo_wine@ErrLev:@space@
+ErrLev: 0
+ErrLev: 0
+ at todo_wine@ErrLev:@space@@or_broken at ErrLev: 0
+ErrLev: 0
+...setlocal with corresponding endlocal
+globalval
+localval
+globalval
+globalval
+...setlocal with no corresponding endlocal
+globalval
+localval
+ at todo_wine@globalval
 -----------Testing Errorlevel-----------
 9009
 1
-- 
1.7.6




More information about the wine-patches mailing list