From 5d27012937307b5027ae28d17715b12ea959cc29 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 22 Oct 2009 16:23:59 -0500 Subject: [svn-r17726] Updated the errorlevel checking for better error handling in the windows batch files. --- windows/c++/test/checkcpptests.bat | 20 ++++++++++++++++---- windows/fortran/test/checkfortrantests.bat | 21 ++++++++++++++++----- windows/hdf5bt.BAT | 10 +++++----- windows/hdf5build.BAT | 16 ++++++++++------ windows/hdf5check.BAT | 21 +++++++++++++++------ windows/hl/c++/test/checkhlcpptests.bat | 21 ++++++++++++++++----- windows/hl/fortran/test/checkhlfortrantests.bat | 21 ++++++++++++++++----- windows/hl/test/checkhltests.bat | 20 ++++++++++++++++---- windows/perform/checkperformtests.bat | 21 ++++++++++++++++----- windows/test/checktests.bat | 21 ++++++++++++++++----- windows/test/testerror.bat | 10 ++++++---- windows/tools/checktools.bat | 21 ++++++++++++++++----- 12 files changed, 164 insertions(+), 59 deletions(-) diff --git a/windows/c++/test/checkcpptests.bat b/windows/c++/test/checkcpptests.bat index e092c04..93ccd2b 100644 --- a/windows/c++/test/checkcpptests.bat +++ b/windows/c++/test/checkcpptests.bat @@ -22,6 +22,8 @@ rem setlocal enabledelayedexpansion pushd %~dp0 +set /a nerrors=0 + rem Clean any variables starting with "HDF5_CPPTEST_", as we use these for our rem tests. Also clear "HDF5_CPPTEST_TESTS", as we will be addding all of our tests rem to this variable. @@ -61,12 +63,16 @@ rem %2 - "dll" or nothing rem Only add our parameters for batch scripts. call !hdf5_cpptest_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. + echo.************************************ + echo. Testing %%a ^(%1 %2^) FAILED + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. - echo.All C++ library tests passed. - exit /b @@ -83,6 +89,12 @@ rem on it for sending parameters. --SJW 9/6/07 rem Run the tests, passing in which version to run call :run_tests %* + if "%nerrors%"=="0" ( + echo.All C++ library tests passed. + ) else ( + echo.** FAILED C++ Library tests. + ) + popd - endlocal & exit /b + endlocal & exit /b %nerrors% \ No newline at end of file diff --git a/windows/fortran/test/checkfortrantests.bat b/windows/fortran/test/checkfortrantests.bat index 2b970f6..e4d7a4e 100644 --- a/windows/fortran/test/checkfortrantests.bat +++ b/windows/fortran/test/checkfortrantests.bat @@ -22,6 +22,8 @@ rem setlocal enabledelayedexpansion pushd %~dp0 +set /a nerrors=0 + rem Clean any variables starting with "HDF5_FORTTEST_", as we use these for our rem tests. Also clear "HDF5_FORTTEST_TESTS", as we will be addding all of our tests rem to this variable. @@ -61,12 +63,16 @@ rem %2 - "dll" or nothing rem Only add our parameters for batch scripts. call !hdf5_forttest_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. + echo.************************************ + echo. Testing %%a ^(%1 %2^) FAILED + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. - echo.All Fortran library tests passed. - exit /b @@ -86,6 +92,11 @@ rem on it for sending parameters. --SJW 9/6/07 rem Run the tests, passing in which version to run call :run_tests %* + if "%nerrors%"=="0" ( + echo.All Fortran library tests passed. + ) else ( + echo.** FAILED Fortran Library tests. + ) + popd - endlocal & exit /b - \ No newline at end of file + endlocal & exit /b %nerrors% diff --git a/windows/hdf5bt.BAT b/windows/hdf5bt.BAT index 5539ce0..13a0671 100755 --- a/windows/hdf5bt.BAT +++ b/windows/hdf5bt.BAT @@ -223,8 +223,8 @@ rem This is where the magic happens :main call :parse_params %* - if %errorlevel% neq 0 ( - if !errorlevel! equ 1 ( + if not errorlevel 0 ( + if errorlevel 1 ( rem This isn't an error case-- this means /? was specified. Simply rem quit. goto end @@ -237,7 +237,7 @@ rem This is where the magic happens ) call :setup - if %errorlevel% neq 0 ( + if not errorlevel 0 ( echo.Error setting up hdf5bt environment! goto error ) @@ -248,13 +248,13 @@ rem This is where the magic happens echo. call :build - if %errorlevel% neq 0 ( + if not errorlevel ( echo.Error building HDF5 libraries! goto error ) call :test - if %errorlevel% neq 0 ( + if not errorlevel 0 ( echo.Error testing HDF5 libraries! goto error ) diff --git a/windows/hdf5build.BAT b/windows/hdf5build.BAT index 30ce1a0..598a0df 100755 --- a/windows/hdf5build.BAT +++ b/windows/hdf5build.BAT @@ -299,7 +299,11 @@ rem Build the HDF5 libraries. By default, C and C++ libraries are built. ) else ( devenv %hdf5_sln% %ccflags% /rebuild "%%a|%hdf5_platform%" ) - if !errorlevel! neq 0 exit /b + if not errorlevel 0 ( + set /a nerrors=!nerrors!+1 + echo. Building %%a FAILED + exit /b 1 + ) ) exit /b @@ -321,8 +325,8 @@ rem This is where the magic happens :main call :parse_params %* - if %errorlevel% neq 0 ( - if !errorlevel! equ 1 ( + if not errorlevel 0 ( + if errorlevel 1 ( rem This isn't an error case-- this means /? was specified. Simply rem quit. goto end @@ -335,7 +339,7 @@ rem This is where the magic happens ) call :setup - if %errorlevel% neq 0 ( + if not errorlevel 0 ( echo.Error setting up build environment. goto error ) @@ -343,7 +347,7 @@ rem This is where the magic happens rem Upgrade the project files if needed if defined hdf5_vs2008 ( call :upgrade - if !errorlevel! neq 0 ( + if not errorlevel 0 ( echo.Error upgrading project files! goto error ) @@ -359,7 +363,7 @@ rem This is where the magic happens call :all - if %errorlevel% neq 0 ( + if not errorlevel 0 ( echo.Error building HDF5 libraries! goto error ) diff --git a/windows/hdf5check.BAT b/windows/hdf5check.BAT index f3caea2..ffa53f0 100755 --- a/windows/hdf5check.BAT +++ b/windows/hdf5check.BAT @@ -75,14 +75,19 @@ rem %2 - "dll" or nothing :run_tests for %%a in (%hdf5_test_tests%) do ( echo. - echo.************************************ + echo.**==**==**==**==**==**==**==**==**==** echo. Testing %%a ^(%1 %2^) - echo.************************************ + echo.**==**==**==**==**==**==**==**==**==** rem Only add our parameters for batch scripts. call !hdf5_test_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. Testing %%a ^(%1 %2^) FAILED + echo.**==**==**==**==**==**==**==**==**==** + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. @@ -118,18 +123,22 @@ rem on it for sending parameters. --SJW 9/6/07 rem We use "nodll" here because we cannot simply leave it blank. Filter rem it out below. --SJW 9/10/07 for %%b in (nodll dll) do ( + echo.====================================== for %%a in (debug release) do ( set hdf5_config=%%a %%b call :run_tests !hdf5_config:nodll=! - if !errorlevel! neq 0 ( + if errorlevel 1 ( set /a nerrors=!nerrors!+1 ) ) + echo.====================================== ) - if %nerrors% equ 0 ( + if "%nerrors%"=="0" ( echo.HDF5 Tests passed for all configurations! - ) + ) else ( + echo.** FAILED HDF5 Tests! + ) popd endlocal & exit /b %nerrors% diff --git a/windows/hl/c++/test/checkhlcpptests.bat b/windows/hl/c++/test/checkhlcpptests.bat index 24b7f55..db3f329 100644 --- a/windows/hl/c++/test/checkhlcpptests.bat +++ b/windows/hl/c++/test/checkhlcpptests.bat @@ -22,6 +22,8 @@ rem setlocal enabledelayedexpansion pushd %~dp0 +set /a nerrors=0 + rem Clean any variables starting with "HDF5_HLCPPTEST_", as we use these for our rem tests. Also clear "HDF5_HLCPPTEST_TESTS", as we will be addding all of our tests rem to this variable. @@ -61,12 +63,16 @@ rem %2 - "dll" or nothing rem Only add our parameters for batch scripts. call !hdf5_hlcpptest_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. + echo.************************************ + echo. Testing %%a ^(%1 %2^) FAILED + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. - echo.All HL C++ library tests passed. - exit /b @@ -82,6 +88,11 @@ rem on it for sending parameters. --SJW 9/6/07 rem Run the tests, passing in which version to run call :run_tests %* + if "%nerrors%"=="0" ( + echo.All HL C++ library tests passed. + ) else ( + echo.** FAILED HL C++ Library tests. + ) + popd - endlocal & exit /b - \ No newline at end of file + endlocal & exit /b %nerrors% diff --git a/windows/hl/fortran/test/checkhlfortrantests.bat b/windows/hl/fortran/test/checkhlfortrantests.bat index 98d9c38..0710625 100644 --- a/windows/hl/fortran/test/checkhlfortrantests.bat +++ b/windows/hl/fortran/test/checkhlfortrantests.bat @@ -22,6 +22,8 @@ rem setlocal enabledelayedexpansion pushd %~dp0 +set /a nerrors=0 + rem Clean any variables starting with "HDF5_HLFORTTEST_", as we use these for our rem tests. Also clear "HDF5_HLFORTTEST_TESTS", as we will be addding all of our tests rem to this variable. @@ -61,12 +63,16 @@ rem %2 - "dll" or nothing rem Only add our parameters for batch scripts. call !hdf5_hlforttest_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. + echo.************************************ + echo. Testing %%a ^(%1 %2^) FAILED + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. - echo.All HL Fortran library tests passed. - exit /b @@ -84,6 +90,11 @@ rem on it for sending parameters. --SJW 9/6/07 rem Run the tests, passing in which version to run call :run_tests %* + if "%nerrors%"=="0" ( + echo.All HL Fortran library tests passed. + ) else ( + echo.** FAILED HL Fortran Library tests. + ) + popd - endlocal & exit /b - \ No newline at end of file + endlocal & exit /b %nerrors% diff --git a/windows/hl/test/checkhltests.bat b/windows/hl/test/checkhltests.bat index 925c245..0804148 100644 --- a/windows/hl/test/checkhltests.bat +++ b/windows/hl/test/checkhltests.bat @@ -22,6 +22,8 @@ rem setlocal enabledelayedexpansion pushd %~dp0 +set /a nerrors=0 + rem Clean any variables starting with "HDF5_HLTEST_", as we use these for our rem tests. Also clear "HDF5_HLTEST_TESTS", as we will be addding all of our tests rem to this variable. @@ -66,12 +68,16 @@ rem %2 - "dll" or nothing rem Only add our parameters for batch scripts. call !hdf5_hltest_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. + echo.************************************ + echo. Testing %%a ^(%1 %2^) FAILED + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. - echo.All HL library tests passed. - exit /b @@ -134,6 +140,12 @@ rem on it for sending parameters. --SJW 9/6/07 rem Run the tests, passing in which version to run call :run_tests %* + if "%nerrors%"=="0" ( + echo.All HL library tests passed. + ) else ( + echo.** FAILED HL Library tests. + ) + popd - endlocal & exit /b + endlocal & exit /b %nerrors% \ No newline at end of file diff --git a/windows/perform/checkperformtests.bat b/windows/perform/checkperformtests.bat index 35895cf..4d789d1 100644 --- a/windows/perform/checkperformtests.bat +++ b/windows/perform/checkperformtests.bat @@ -22,6 +22,8 @@ rem setlocal enabledelayedexpansion pushd %~dp0 +set /a nerrors=0 + rem Clean any variables starting with "HDF5_PERFTEST_", as we use these for our rem tests. Also clear "HDF5_PERFTEST_TESTS", as we will be addding all of our tests rem to this variable. @@ -61,12 +63,16 @@ rem %2 - "dll" or nothing rem Only add our parameters for batch scripts. call !hdf5_perftest_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. + echo.************************************ + echo. Testing %%a ^(%1 %2^) FAILED + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. - echo.All performance tests passed. - exit /b @@ -85,6 +91,11 @@ rem on it for sending parameters. --SJW 9/6/07 rem Run the tests, passing in which version to run call :run_tests %* + if "%nerrors%"=="0" ( + echo.All performance tests passed. + ) else ( + echo.** FAILED performance tests. + ) + popd - endlocal & exit /b - \ No newline at end of file + endlocal & exit /b %nerrors% diff --git a/windows/test/checktests.bat b/windows/test/checktests.bat index 6b11615..2665836 100644 --- a/windows/test/checktests.bat +++ b/windows/test/checktests.bat @@ -22,6 +22,8 @@ rem setlocal enabledelayedexpansion pushd %~dp0 +set /a nerrors=0 + rem Clean any variables starting with "HDF5_LIBTEST_", as we use these for our rem tests. Also clear "HDF5_LIBTEST_TESTS", as we will be addding all of our tests rem to this variable. @@ -61,12 +63,16 @@ rem %2 - "dll" or nothing rem Only add our parameters for batch scripts. call !hdf5_libtest_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. + echo.************************************ + echo. Testing %%a ^(%1 %2^) FAILED + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. - echo.All library tests passed. - exit /b @@ -131,6 +137,11 @@ rem on it for sending parameters. --SJW 9/6/07 rem Run the tests, passing in which version to run call :run_tests %* + if "%nerrors%"=="0" ( + echo.All library tests passed. + ) else ( + echo.** FAILED Library tests. + ) + popd - endlocal & exit /b - \ No newline at end of file + endlocal & exit /b %nerrors% diff --git a/windows/test/testerror.bat b/windows/test/testerror.bat index 844e69c..24d39e0 100644 --- a/windows/test/testerror.bat +++ b/windows/test/testerror.bat @@ -146,11 +146,11 @@ rem ) fc /w %expect1_parsed% %actual% > nul - if %errorlevel% equ 0 ( + if errorlevel 0 ( call :testing PASSED %test_err% ) else ( fc /w %expect2_parsed% %actual% > nul - if !errorlevel! equ 0 ( + if errorlevel 0 ( call :testing PASSED %test_err% ) else ( call :testing *FAILED* %test_err% @@ -193,9 +193,11 @@ rem ############################################################################ rem test for error_test call :test error_test %1 %2 - if %nerrors% equ 0 ( + if "%nerrors%"=="0" ( echo.All Error API tests passed. - ) + ) else ( + echo.** FAILED Error API tests + ) popd endlocal & exit /b %nerrors% diff --git a/windows/tools/checktools.bat b/windows/tools/checktools.bat index f5a5b82..376e1fb 100644 --- a/windows/tools/checktools.bat +++ b/windows/tools/checktools.bat @@ -22,6 +22,8 @@ rem setlocal enabledelayedexpansion pushd %~dp0 +set /a nerrors=0 + rem Clean any variables starting with "HDF5_TOOL_", as we use these for our rem tests. Also clear "HDF5_TOOL_TESTS", as we will be addding all of our tests rem to this variable. @@ -61,12 +63,16 @@ rem %2 - "dll" or nothing rem Only add our parameters for batch scripts. call !hdf5_tool_%%a_test:.bat= %1 %2! rem Exit early if test fails. - if !errorlevel! neq 0 exit /b + if errorlevel 1 ( + set /a nerrors=!nerrors!+1 + echo. + echo.************************************ + echo. Testing %%a ^(%1 %2^) FAILED + exit /b 1 + ) ) rem If we get here, that means all of our tests passed. - echo.All tool tests passed. - exit /b @@ -147,6 +153,11 @@ rem on it for sending parameters. --SJW 9/6/07 rem Run the tests, passing in which version to run call :run_tests %* + if "%nerrors%"=="0" ( + echo.All tool tests passed. + ) else ( + echo.** FAILED tool tests. + ) + popd - endlocal & exit /b - \ No newline at end of file + endlocal & exit /b %nerrors% -- cgit v0.12