@echo off :: This batch runs the tests stored in /test/schemas/. echo ## W3C XML Schema regression tests setlocal :: This batch makes use of "sed.exe"; exit if it is not available. set SEDEXE=sed.exe set EXE_FOUND= if exist %SEDEXE% set EXE_FOUND=1 if "%EXE_FOUND%" == "1" goto :start for %%d in (%path%) do if exist %%d\%SEDEXE% set EXE_FOUND=1 if "%EXE_FOUND%" == "1" goto :start for %%d in (%path%) do if exist %%d%SEDEXE% set EXE_FOUND=1 if "%EXE_FOUND%" == "1" goto :start echo mandatory %SEDEXE% is not at path or the current directory echo tests aborted! goto :EOF :start set BINDIR=%1 set XML_SRCDIR=%2 echo.> .memdump for %%I in (%XML_SRCDIR%\test\schemas\*_*.xsd) do ( set XSDNAME=%%~nxI call :iterXML ) endlocal goto :EOF :iterXML call :varset xsd for %%J in (%XML_SRCDIR%\test\schemas\%TESTNAME%_*.xml) do call :test %%~nxJ goto :EOF :test call :varset xml %1 set RESULTID=%XML_SRCDIR%\result\schemas\%TESTNAME%_%XSDNO%_%XMLNO% :: echo vars: %TESTNAME%, %XSDNAME%, [%XSDNO%], %XMLNAME%, [%XMLNO%] :: echo resultid: %RESULTID% IF EXIST rep.%TESTNAME% (del rep.%TESTNAME%) IF NOT EXIST %XML_SRCDIR%\result\schemas\%TESTNAME%_%XSDNO%_%XMLNO% ( echo New test %TESTNAME%_%XSDNO%_%XMLNO% %BINDIR%\testSchemas.exe %XML_SRCDIR%\test\schemas\%XSDNAME% %XML_SRCDIR%\test\schemas\%XMLNAME% >res.%TESTNAME%.tmp 2>err.%TESTNAME%.tmp call :linOutput res.%TESTNAME%.tmp %RESULTID% call :linOutput err.%TESTNAME%.tmp %RESULTID%.err call :checkMemory call :checkUnimplemented %RESULTID%.err ) ELSE ( %BINDIR%\testSchemas.exe %XML_SRCDIR%\test\schemas\%XSDNAME% %XML_SRCDIR%\test\schemas\%XMLNAME% 1>res.%TESTNAME%.tmp 2>err.%TESTNAME%.tmp call :linOutput res.%TESTNAME%.tmp res.%TESTNAME% call :linOutput err.%TESTNAME%.tmp err.%TESTNAME% call :checkMemory :: Compare outputs with expected outputs. call :compare %RESULTID% res.%TESTNAME% "std output differs:" call :compare %RESULTID%.err err.%TESTNAME% "err output differs:" call :checkUnimplemented err.%TESTNAME% del res.%TESTNAME% del err.%TESTNAME% ) :: Report errors. IF EXIST rep.%TESTNAME% ( type rep.%TESTNAME% del rep.%TESTNAME% ) goto :EOF :linOutput :: Transforms the output to be conformant with the Linux output. :: Note: this might not be robust enough; please change if you know better. sed -e "s/\\/\//g" -e "s/.*.\/test\/schemas/.\/test\/schemas/" %1 >%2 del %1 goto :EOF :checkMemory :: Report memory leaks. :: echo MEMORY ALLOCATED : 99 >.memdump IF EXIST .memdump ( find "MEMORY ALLOCATED" .memdump >nul if not ERRORLEVEL 1 ( find "MEMORY ALLOCATED : 0" .memdump >nul if ERRORLEVEL 1 ( call :createReport >>rep.%TESTNAME% type .memdump ) ) ) ELSE ( echo No memdump! ) goto :EOF :checkUnimplemented :: Check for unimplemented blocks. :: echo Unimplemented block at line foo >>%1 find "Unimplemented" %1 >nul if not ERRORLEVEL 1 ( call :createReport >>rep.%TESTNAME% findstr "Unimplemented" %1 ) goto :EOF :compare fc /A /LB1 %1 %2 | find "*" >nul if not ERRORLEVEL 1 ( call :createReport >>rep.%TESTNAME% echo %~3 >>rep.%TESTNAME% type %2 >>rep.%TESTNAME% echo expected: >>rep.%TESTNAME% type %1 ) goto :EOF :varset :: Set environment variables using a temp batch file. :: This is inconvenient; please change if you know better. echo echo off>_varset.bat if [%1] == [xsd] ( echo SET TESTNAME=%XSDNAME%|sed "s+_.*++">>_varset.bat >>_varset.bat echo SET XSDNO=^^ echo %XSDNAME%|sed "s+.*_\(.*\).xsd+\1+">>_varset.bat call _varset.bat ) if [%1] == [xml] ( echo SET XMLNAME=%2>>_varset.bat >>_varset.bat echo SET XMLNO=^^ echo %2|sed "s+.*_\(.*\).xml+\1+">>_varset.bat call _varset.bat ) del _varset.bat goto :EOF :createReport if NOT EXIST rep.%TESTNAME% echo %TESTNAME%_%XSDNO%_%XMLNO% result: >rep.%TESTNAME% goto :EOF :EOF