[CMake] Batch Files in CTest (instead executables)

David Graf david.graf at 28msec.com
Thu Apr 1 02:50:58 EDT 2010


Hello David

The problem I have is not located in the batch file. The EXIT is executed. But if the /B option is on, ctest doesn't detect failures anymore. The batch script must be killed by executing EXIT without the '/B' options. But then, the batch script cannot be used anymore from the command line because it kills the command line all the time.

I didn't find a clean solution in the meantime. Now, I am using different scripts. One to execute executables form ctest (without /B option). And one to execute executables from the command line (with /B option).

David

On Mar 31, 2010, at 7:34 PM, David Cole wrote:

> Try something like this instead:
> SETLOCAL
> SET PATH=...;%PATH%
> execute_something.exe
> set my_error=%ERRORLEVEL%
> IF %my_error% neq 0 (
>  EXIT /B %my_error%
> )
> ENDLOCAL
> 
> I think the problem is probably that ERRORLEVEL is changing to 0 after you execute the batch script IF command... Saving it in your own variable prevents that sort of "sole last error" madness...
> 
> Let me know if that does not work. This should be working as you expect.
> 
> 
> On Wed, Mar 31, 2010 at 3:59 AM, David Graf <david.graf at 28msec.com> wrote:
> 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
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100401/e374b92a/attachment.htm>


More information about the CMake mailing list