for /l %%i in (1,1,%expectedresults%) do call :WriteLine if not "%%%%expectedresults.%%i%%%%"=="" echo Found missing result: "%%%%expectedresults.%%i%%%%"
for /l %%i in (1,1,%WINE_expectedresults%) do (
call :WriteLine if not "%%%%WINE_expectedresults.%%i%%%%"=="" echo Found missing result: "%%%%WINE_expectedresults.%%i%%%%"
)
call temp.bat
del temp.bat 2>nul
goto :eof
:TestForR
rem %CD% does not tork on NT4 so use the following workaround
for /d %%i in (.) do set CURDIR=%%~dpnxi
for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi
echo --- for /R
echo Plain directory enumeration
set expectedresults=4
set expectedresults.1=%CURDIR%\.
set expectedresults.2=%CURDIR%\bar\.
set expectedresults.3=%CURDIR%\baz\.
set expectedresults.4=%CURDIR%\foo\.
set WINE_expectedresults=4
set WINE_expectedresults.1=%WINE_CURDIR%\.
set WINE_expectedresults.2=%WINE_CURDIR%\bar\.
set WINE_expectedresults.3=%WINE_CURDIR%\baz\.
set WINE_expectedresults.4=%WINE_CURDIR%\foo\.
call :SetExpected
for /R %%i in (.) do call temp.bat %%i
call :ValidateExpected
echo Plain directory enumeration from provided root
set expectedresults=4
set expectedresults.1=%CURDIR%\.
set expectedresults.2=%CURDIR%\bar\.
set expectedresults.3=%CURDIR%\baz\.
set expectedresults.4=%CURDIR%\foo\.
set WINE_expectedresults=4
set WINE_expectedresults.1=%WINE_CURDIR%\.
set WINE_expectedresults.2=%WINE_CURDIR%\bar\.
set WINE_expectedresults.3=%WINE_CURDIR%\baz\.
set WINE_expectedresults.4=%WINE_CURDIR%\foo\.
if "%CD%"=="" goto :SkipBrokenNT4
call :SetExpected
for /R "%CURDIR%" %%i in (.) do call temp.bat %%i
for /R "%WINE_CURDIR%" %%i in (.) do call temp.bat %%i
call :ValidateExpected
:SkipBrokenNT4
echo File enumeration
set expectedresults=2
set expectedresults.1=%CURDIR%\baz\bazbaz
set expectedresults.2=%CURDIR%\bazbaz
set WINE_expectedresults=2
set WINE_expectedresults.1=%WINE_CURDIR%\baz\bazbaz
set WINE_expectedresults.2=%WINE_CURDIR%\bazbaz
call :SetExpected
for /R %%i in (baz*) do call temp.bat %%i
call :ValidateExpected
echo File enumeration from provided root
set expectedresults=2
set expectedresults.1=%CURDIR%\baz\bazbaz
set expectedresults.2=%CURDIR%\bazbaz
set WINE_expectedresults=2
set WINE_expectedresults.1=%WINE_CURDIR%\baz\bazbaz
set WINE_expectedresults.2=%WINE_CURDIR%\bazbaz
call :SetExpected
for /R %%i in (baz*) do call temp.bat %%i
call :ValidateExpected
echo Mixed enumeration
set expectedresults=6
set expectedresults.1=%CURDIR%\.
set expectedresults.2=%CURDIR%\bar\.
set expectedresults.3=%CURDIR%\baz\.
set expectedresults.4=%CURDIR%\baz\bazbaz
set expectedresults.5=%CURDIR%\bazbaz
set expectedresults.6=%CURDIR%\foo\.
set WINE_expectedresults=6
set WINE_expectedresults.1=%WINE_CURDIR%\.
set WINE_expectedresults.2=%WINE_CURDIR%\bar\.
set WINE_expectedresults.3=%WINE_CURDIR%\baz\.
set WINE_expectedresults.4=%WINE_CURDIR%\baz\bazbaz
set WINE_expectedresults.5=%WINE_CURDIR%\bazbaz
set WINE_expectedresults.6=%WINE_CURDIR%\foo\.
call :SetExpected
for /R %%i in (. baz*) do call temp.bat %%i
call :ValidateExpected
echo Mixed enumeration from provided root
set expectedresults=6
set expectedresults.1=%CURDIR%\.
set expectedresults.2=%CURDIR%\bar\.
set expectedresults.3=%CURDIR%\baz\.
set expectedresults.4=%CURDIR%\baz\bazbaz
set expectedresults.5=%CURDIR%\bazbaz
set expectedresults.6=%CURDIR%\foo\.
set WINE_expectedresults=6
set WINE_expectedresults.1=%WINE_CURDIR%\.
set WINE_expectedresults.2=%WINE_CURDIR%\bar\.
set WINE_expectedresults.3=%WINE_CURDIR%\baz\.
set WINE_expectedresults.4=%WINE_CURDIR%\baz\bazbaz
set WINE_expectedresults.5=%WINE_CURDIR%\bazbaz
set WINE_expectedresults.6=%WINE_CURDIR%\foo\.
call :SetExpected
for /R %%i in (. baz*) do call temp.bat %%i
call :ValidateExpected
echo With duplicates enumeration
set expectedresults=12
set expectedresults.1=%CURDIR%\bar\bazbaz
set expectedresults.2=%CURDIR%\bar\fred
set expectedresults.3=%CURDIR%\baz\bazbaz
set expectedresults.4=%CURDIR%\baz\bazbaz
set expectedresults.5=%CURDIR%\baz\bazbaz
set expectedresults.6=%CURDIR%\baz\fred
set expectedresults.7=%CURDIR%\bazbaz
set expectedresults.8=%CURDIR%\bazbaz
set expectedresults.9=%CURDIR%\bazbaz
set expectedresults.10=%CURDIR%\foo\bazbaz
set expectedresults.11=%CURDIR%\foo\fred
set expectedresults.12=%CURDIR%\fred
set WINE_expectedresults=12
set WINE_expectedresults.1=%WINE_CURDIR%\bar\bazbaz
set WINE_expectedresults.2=%WINE_CURDIR%\bar\fred
set WINE_expectedresults.3=%WINE_CURDIR%\baz\bazbaz
set WINE_expectedresults.4=%WINE_CURDIR%\baz\bazbaz
set WINE_expectedresults.5=%WINE_CURDIR%\baz\bazbaz
set WINE_expectedresults.6=%WINE_CURDIR%\baz\fred
set WINE_expectedresults.7=%WINE_CURDIR%\bazbaz
set WINE_expectedresults.8=%WINE_CURDIR%\bazbaz
set WINE_expectedresults.9=%WINE_CURDIR%\bazbaz
set WINE_expectedresults.10=%WINE_CURDIR%\foo\bazbaz
set WINE_expectedresults.11=%WINE_CURDIR%\foo\fred
set WINE_expectedresults.12=%WINE_CURDIR%\fred
call :SetExpected
for /R %%i in (baz* bazbaz fred ba*) do call temp.bat %%i
if exist foo (echo foo created) else echo foo should exist!
rmdir foo
set FOOBAZ_VAR=foobaz
call echo Should expand %FOOBAZ_VAR%
set FOOBAZ_VAR=
set WINE_FOOBAZ_VAR=foobaz
call echo Should expand %WINE_FOOBAZ_VAR%
set WINE_FOOBAZ_VAR=
echo>batfile
call dir /b
echo>robinfile
...
...
@@ -1889,14 +1894,14 @@ if not exist "%1" (
echo Failed: File missing when requested filesize check [%2]
goto :ContinueFileSizeChecks
)
for %%i in (%1) do set filesize=%%~zi
if "%filesize%"=="%2" (
echo Passed: file size check on %1 [%filesize%]
for %%i in (%1) do set WINE_filesize=%%~zi
if "%WINE_filesize%"=="%2" (
echo Passed: file size check on %1 [%WINE_filesize%]
) else (
if "%filesize%"=="%%~zi" (
if "%WINE_filesize%"=="%%~zi" (
echo Skipping file size check on NT4
) else (
echo Failed: file size check on %1 [%filesize% != %2]
echo Failed: file size check on %1 [%WINE_filesize% != %2]
)
)
:ContinueFileSizeChecks
...
...
@@ -2171,164 +2176,164 @@ 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
rem %CD% does not tork on NT4 so use the following workaround
for /d %%i in (.) do set CURDIR=%%~dpnxi
for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi
echo @echo off> test.cmd
echo echo %%VAR%%>> test.cmd
echo echo %%WINE_VAR%%>> test.cmd
echo setlocal>> test.cmd
echo set VAR=localval>> test.cmd
echo set WINE_VAR=localval>> test.cmd
echo md foobar2>> test.cmd
echo cd foobar2>> test.cmd
echo echo %%VAR%%>> test.cmd
echo echo %%WINE_VAR%%>> test.cmd
echo for /d %%%%i in (.) do echo %%%%~dpnxi>> test.cmd
echo endlocal>> test.cmd
echo echo %%VAR%%>> test.cmd
echo echo %%WINE_VAR%%>> test.cmd
echo for /d %%%%i in (.) do echo %%%%~dpnxi>> test.cmd
set VAR=globalval
set WINE_VAR=globalval
call test.cmd
echo %VAR%
echo %WINE_VAR%
for /d %%i in (.) do echo %%~dpnxi
cd /d %curdir%
cd /d %WINE_CURDIR%
rd foobar2
set VAR=
set WINE_VAR=
echo --- setlocal with no corresponding endlocal
echo @echo off> test.cmd
echo echo %%VAR%%>> test.cmd
echo echo %%WINE_VAR%%>> test.cmd
echo setlocal>> test.cmd
echo set VAR=localval>> test.cmd
echo set WINE_VAR=localval>> test.cmd
echo md foobar2>> test.cmd
echo cd foobar2>> test.cmd
echo echo %%VAR%%>> test.cmd
echo echo %%WINE_VAR%%>> test.cmd
echo for /d %%%%i in (.) do echo %%%%~dpnxi>> test.cmd
set VAR=globalval
set WINE_VAR=globalval
rem %CD% does not tork on NT4 so use the following workaround
for /d %%i in (.) do set CURDIR=%%~dpnxi
for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi
call test.cmd
echo %VAR%
echo %WINE_VAR%
for /d %%i in (.) do echo %%~dpnxi
cd /d %curdir%
cd /d %WINE_CURDIR%
rd foobar2
set VAR=
set WINE_VAR=
echo --- setlocal within same batch program
set var1=one
set var2=
set var3=
set WINE_var1=one
set WINE_var2=
set WINE_var3=
rem %CD% does not tork on NT4 so use the following workaround
for /d %%i in (.) do set CURDIR=%%~dpnxi
for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi
setlocal
set var2=two
set WINE_var2=two
mkdir foobar2
cd foobar2
setlocal
set var3=three
if "%var1%"=="one" echo Var1 ok 1
if "%var2%"=="two" echo Var2 ok 2
if "%var3%"=="three" echo Var3 ok 3
for /d %%i in (.) do set curdir2=%%~dpnxi
if "%curdir2%"=="%curdir%\foobar2" echo Directory is ok 1
set WINE_var3=three
if "%WINE_var1%"=="one" echo Var1 ok 1
if "%WINE_var2%"=="two" echo Var2 ok 2
if "%WINE_var3%"=="three" echo Var3 ok 3
for /d %%i in (.) do set WINE_curdir2=%%~dpnxi
if "%WINE_curdir2%"=="%WINE_CURDIR%\foobar2" echo Directory is ok 1
endlocal
if "%var1%"=="one" echo Var1 ok 1
if "%var2%"=="two" echo Var2 ok 2
if "%var3%"=="" echo Var3 ok 3
for /d %%i in (.) do set curdir2=%%~dpnxi
if "%curdir2%"=="%curdir%\foobar2" echo Directory is ok 2
if "%WINE_var1%"=="one" echo Var1 ok 1
if "%WINE_var2%"=="two" echo Var2 ok 2
if "%WINE_var3%"=="" echo Var3 ok 3
for /d %%i in (.) do set WINE_curdir2=%%~dpnxi
if "%WINE_curdir2%"=="%WINE_CURDIR%\foobar2" echo Directory is ok 2
endlocal
if "%var1%"=="one" echo Var1 ok 1
if "%var2%"=="" echo Var2 ok 2
if "%var3%"=="" echo Var3 ok 3
for /d %%i in (.) do set curdir2=%%~dpnxi
if "%curdir2%"=="%curdir%" echo Directory is ok 3
if "%WINE_var1%"=="one" echo Var1 ok 1
if "%WINE_var2%"=="" echo Var2 ok 2
if "%WINE_var3%"=="" echo Var3 ok 3
for /d %%i in (.) do set WINE_curdir2=%%~dpnxi
if "%WINE_curdir2%"=="%WINE_CURDIR%" echo Directory is ok 3
rd foobar2 /s /q
set var1=
set WINE_var1=
echo --- Mismatched set and end locals
mkdir foodir2 2>nul
mkdir foodir3 2>nul
mkdir foodir4 2>nul
rem %CD% does not tork on NT4 so use the following workaround
for /d %%i in (.) do set curdir=%%~dpnxi
for /d %%i in (.) do set WINE_curdir=%%~dpnxi
echo @echo off> 2set1end.cmd
echo echo %%VAR%%>> 2set1end.cmd
echo echo %%WINE_var%%>> 2set1end.cmd
echo setlocal>> 2set1end.cmd
echo set VAR=2set1endvalue1>> 2set1end.cmd
echo set WINE_VAR=2set1endvalue1>> 2set1end.cmd
echo cd ..\foodir3>> 2set1end.cmd
echo setlocal>> 2set1end.cmd
echo set VAR=2set1endvalue2>> 2set1end.cmd
echo set WINE_VAR=2set1endvalue2>> 2set1end.cmd
echo cd ..\foodir4>> 2set1end.cmd
echo endlocal>> 2set1end.cmd
echo echo %%VAR%%>> 2set1end.cmd
echo echo %%WINE_var%%>> 2set1end.cmd
echo for /d %%%%i in (.) do echo %%%%~dpnxi>> 2set1end.cmd
echo @echo off> 1set2end.cmd
echo echo %%VAR%%>> 1set2end.cmd
echo echo %%WINE_var%%>> 1set2end.cmd
echo setlocal>> 1set2end.cmd
echo set VAR=1set2endvalue1>> 1set2end.cmd
echo set WINE_VAR=1set2endvalue1>> 1set2end.cmd
echo cd ..\foodir3>> 1set2end.cmd
echo endlocal>> 1set2end.cmd
echo echo %%VAR%%>> 1set2end.cmd
echo echo %%WINE_var%%>> 1set2end.cmd
echo for /d %%%%i in (.) do echo %%%%~dpnxi>> 1set2end.cmd
echo endlocal>> 1set2end.cmd
echo echo %%VAR%%>> 1set2end.cmd
echo echo %%WINE_var%%>> 1set2end.cmd
echo for /d %%%%i in (.) do echo %%%%~dpnxi>> 1set2end.cmd
echo --- Extra setlocal in called batch
set VAR=value1
set WINE_VAR=value1
rem -- setlocal1 == this batch, should never be used inside a called routine
setlocal
set var=value2
set WINE_var=value2
cd foodir2
call %curdir%\2set1end.cmd
call %WINE_CURDIR%\2set1end.cmd
echo Finished:
echo %VAR%
echo %WINE_VAR%
for /d %%i in (.) do echo %%~dpnxi
endlocal
echo %VAR%
echo %WINE_VAR%
for /d %%i in (.) do echo %%~dpnxi
cd /d %curdir%
cd /d %WINE_CURDIR%
echo --- Extra endlocal in called batch
set VAR=value1
set WINE_VAR=value1
rem -- setlocal1 == this batch, should never be used inside a called routine
setlocal
set var=value2
set WINE_var=value2
cd foodir2
call %curdir%\1set2end.cmd
call %WINE_CURDIR%\1set2end.cmd
echo Finished:
echo %VAR%
echo %WINE_VAR%
for /d %%i in (.) do echo %%~dpnxi
endlocal
echo %VAR%
echo %WINE_VAR%
for /d %%i in (.) do echo %%~dpnxi
cd /d %curdir%
cd /d %WINE_CURDIR%
echo --- endlocal in called function rather than batch pgm is ineffective