1 echo Tests for cmd's builtin commands
4 echo ------------ Testing 'echo' [ON] --------------
6 echo 'singlequotedword'
7 echo "doublequotedword"
15 echo word@space@@space@
18 echo ------------ Testing 'echo' [OFF] --------------
20 echo 'singlequotedword'
21 echo "doublequotedword"
29 echo word@space@@space@
31 echo ------------ Testing 'set' --------------
33 set FOOBAR 2> nul > nul
37 echo %FOOBAR%FOOBAR not defined
49 echo %FOOBAR%FOOBAR not defined
51 set FOOBA 2> nul > nul
61 echo %FOO%FOO not defined
66 echo set "FOO=bar" should not include the quotes in the variable value
71 echo ------------ Testing variable expansion --------------
73 echo ~dp0 should be directory containing batch file
89 echo %ERRORLEVEL%%ERRORLEVEL%
90 echo %ERRORLEVEL%ERRORLEVEL%
97 echo ------------ Testing type ------------
107 echo ------------ Testing if/else --------------
108 echo if/else should work with blocks
110 echo if seems to work
112 echo if seems to be broken
115 echo else seems to be broken
117 echo else seems to work
120 echo if seems not to detect /c as parameter
122 echo parameter detection seems to be broken
124 echo Testing case sensitivity with and without /i option
125 if bar==BAR echo if does not default to case sensitivity
126 if not bar==BAR echo if seems to default to case sensitivity
127 if /i foo==FOO echo if /i seems to work
128 if /i not foo==FOO echo if /i seems to be broken
129 if /I foo==FOO echo if /I seems to work
130 if /I not foo==FOO echo if /I seems to be broken
132 echo -----------Testing for -----------
133 for %%i in (A B C) do echo %%i
134 for %%i in (A B C) do call :forTestFun1 %%i
143 for %%i in (A B) do (
144 for %%j in (C D) do (
146 for %%i in (A B) do (
147 for %%j in (C D) do (
148 call :forTestFun2 %%i %%j ))
155 echo -----------Testing del /a-----------
156 del /f/q *.test > nul
159 echo not-r > not-r.test
161 if not exist not-r.test echo not-r.test not found before delete, bad
163 if not exist not-r.test echo not-r.test not found after delete, good
165 if not exist r.test echo r.test not found before delete, bad
166 if exist r.test echo r.test found before delete, good
168 if not exist r.test echo r.test not found after delete, good
169 if exist r.test echo r.test found after delete, bad
171 echo ------------ Testing del /q --------------
176 rem If /q doesn't work, cmd will prompt and the test case should hang
178 for %%a in (1 2.dat) do if exist file%%a echo del /q * failed on file%%a
179 for %%a in (1 2.dat) do if not exist file%%a echo del /q * succeeded on file%%a
183 echo ------------ Testing del /s --------------
187 echo there > file2.dat
189 echo bye > "file with spaces.dat"
191 del /s file1.dat > nul
192 del file2.dat /s > nul
193 del "file3.dat" /s > nul
194 del "file with spaces.dat" /s > nul
196 for %%f in (1 2 3) do if exist file%%f.dat echo Del /s failed on file%%f
197 for %%f in (1 2 3) do if exist file%%f.dat del file%%f.dat
198 if exist "file with spaces.dat" echo Del /s failed on "file with spaces.dat"
199 if exist "file with spaces.dat" del "file with spaces.dat"
203 echo ----------- Testing mkdir -----------
205 rem md and mkdir are synonymous
212 rem Creating an already existing directory/file must fail
221 rem Multi-level path creation
233 mkdir ..\..\..\foo\bar2
236 mkdir ..\..\..\foo\bar2
238 rmdir ..\..\..\foo\bar2
246 rem Trailing backslashes
249 if exist foo (rmdir foo && echo dir created
250 ) else ( echo dir not created )
261 if exist foo (rmdir foo && echo ok, foo created
262 ) else ( echo foo not created )
268 echo bad, foo not created
272 echo ok, foo\bar created
279 echo ----------- Testing rmdir -----------
281 rem rd and rmdir are synonymous
285 if not exist foobar echo dir removed
289 if not exist foobar echo dir removed
290 rem Removing non-existent directory
293 rem Removing single-level directories
297 if exist foo echo file not removed
303 if exist foo echo non-empty dir not removed
308 if exist foo echo non-empty dir not removed
312 echo -----------Testing Errorlevel-----------
313 rem nt 4.0 doesn't really support a way of setting errorlevel, so this is weak
314 rem See http://www.robvanderwoude.com/exit.php
317 if errorlevel 2 echo errorlevel too high, bad
318 if errorlevel 1 echo errorlevel just right, good
320 echo abc%ErrorLevel%def
321 if errorlevel 1 echo errorlevel nonzero, bad
322 if not errorlevel 1 echo errorlevel zero, good
323 rem Now verify that setting a real variable hides its magic variable
325 echo %ErrorLevel% should be 7
326 if errorlevel 7 echo setting var worked too well, bad
328 echo %ErrorLevel% should still be 7
330 echo -----------Testing GOTO-----------
333 echo goto with no leading space worked
336 echo goto with a leading space worked
339 echo goto with a leading tab worked
342 echo goto with a following space worked
344 echo -----------Done, jumping to EOF-----------
346 rem Subroutine to set errorlevel and return
347 rem in windows nt 4.0, this always sets errorlevel 1, since /b isn't supported
350 rem This line runs under cmd in windows NT 4, but not in more modern versions.