[CMake] Batch Files in CTest (instead executables)
David Cole
david.cole at kitware.com
Wed Mar 31 13:34:13 EDT 2010
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/20100331/4d23da3d/attachment.htm>
More information about the CMake
mailing list