Dan Kegel : cmd: Add simple test for %errorlevel%.

Alexandre Julliard julliard at winehq.org
Thu May 26 10:56:27 CDT 2011


Module: wine
Branch: master
Commit: 67873bdc9f2dc8ee905dd5f748e266e7137da06d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=67873bdc9f2dc8ee905dd5f748e266e7137da06d

Author: Dan Kegel <dank at kegel.com>
Date:   Wed May 25 21:42:37 2011 -0700

cmd: Add simple test for %errorlevel%.

---

 programs/cmd/tests/test_builtins.cmd     |   26 ++++++++++++++++++++++++++
 programs/cmd/tests/test_builtins.cmd.exp |    8 ++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 62dbc6c..2763d7c 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -94,6 +94,24 @@ del /a:r *.test
 if not exist r.test echo r.test not found after delete, good
 if exist r.test echo r.test found after delete, bad
 
+echo -----------Testing Errorlevel-----------
+rem nt 4.0 doesn't really support a way of setting errorlevel, so this is weak
+rem See http://www.robvanderwoude.com/exit.php
+call :setError 1
+echo %ErrorLevel%
+if errorlevel 2 echo errorlevel too high, bad
+if errorlevel 1 echo errorlevel just right, good
+call :setError 0
+echo abc%ErrorLevel%def
+if errorlevel 1 echo errorlevel nonzero, bad
+if not errorlevel 1 echo errorlevel zero, good
+rem Now verify that setting a real variable hides its magic variable
+set errorlevel=7
+echo %ErrorLevel% should be 7
+if errorlevel 7 echo setting var worked too well, bad
+call :setError 3
+echo %ErrorLevel% should still be 7
+
 echo -----------Testing GOTO-----------
 if a==a goto dest1
 :dest1
@@ -107,3 +125,11 @@ echo goto with a leading tab worked
 if d==d goto dest4
 :dest4 at space@
 echo goto with a following space worked
+
+echo -----------Done, jumping to EOF-----------
+goto :eof
+rem Subroutine to set errorlevel and return
+rem in windows nt 4.0, this always sets errorlevel 1, since /b isn't supported
+:setError
+exit /B %1
+rem This line runs under cmd in windows NT 4, but not in more modern versions.
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 0dcd926..c185eb0 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -82,8 +82,16 @@ if /I seems to work
 not-r.test not found after delete, good
 r.test found before delete, good
 r.test not found after delete, good
+-----------Testing Errorlevel-----------
+1
+errorlevel just right, good
+abc0def at or_broken@abc1def
+errorlevel zero, good at or_broken@errorlevel nonzero, bad
+7 should be 7
+7 should still be 7
 -----------Testing GOTO-----------
 goto with no leading space worked
 goto with a leading space worked
 goto with a leading tab worked
 goto with a following space worked
+-----------Done, jumping to EOF-----------




More information about the wine-cvs mailing list