[CMake] Batch Files in CTest (instead executables)

David Graf david.graf at 28msec.com
Wed Mar 31 03:59:09 EDT 2010


Hello Everybody

I want to execute batch files in CTest tests (to set the correct paths to the PATH environment variables before executing an executable). Unfortunately, that does not work smoothly. The reason is the error handling.
If an error happens in the batch file, the batch file has to be killed with an exit command. Otherwise, ctest doesn't receive an error code. My script has to look like this:

SETLOCAL
SET PATH=...;%PATH%
execute_something.exe
IF %ERRORLEVEL% neq 0 ( 
  EXIT %ERRORLEVEL%
)
ENDLOCAL


Unfortunately, this is not handy because the batch file cannot be executed anymore from the cmd. Actually, it can. But it kills that cmd every time an error happens. Not really nice. In my opinion, the batch file should look like this:

SETLOCAL
SET PATH=...;%PATH%
execute_something.exe
IF %ERRORLEVEL% neq 0 ( 
  EXIT /B %ERRORLEVEL%
)
ENDLOCAL

Because of the argument '/B', the cmd is not killed anymore, but the error code is correctly set! Unfortunately, ctest doesn't behave correctly anymore after this change. After this change, every test passes. No matter what is going on. CTest doesn't seem to check the %ERRORLEVEL%.

Is this a missing feature in ctest? Or am I missing something?

Cheers,

David Graf




More information about the CMake mailing list