[CMake] CMakeLists.txt: How to print a message if ctest fails?
Muhammad Osama
osama94 at gmail.com
Tue Apr 19 13:10:46 EDT 2016
Hi Miroslav,
That makes sense, is there a way I can make ctest -S CTestScript.cmake command
replace the regular ctest? I don't want users who run ctest type the whole
thing.
Thank you,
On Tue, Apr 19, 2016 at 1:18 AM, Matějů Miroslav, Ing. <
Mateju.Miroslav at azd.cz> wrote:
> Hi Muhammad,
>
>
>
> You need to add this code to a separate CTest script (CTestScript.cmake,
> for example) and then run it using ctest -S CTestScript.cmake. Since the
> wiki page I linked yesterday provides only some complex examples, I am
> sending the key part of my CTest script. As you can see, its operation
> strongly depends on environment variables (some of them are provided by
> Windows). You’ll probably need to remove most of my if’s.
>
>
>
> set(CTEST_SOURCE_DIRECTORY "$ENV{SCRIPT_FOLDER}")
>
> set(CTEST_BINARY_DIRECTORY "$ENV{BINARY_PROJECT_FOLDER}")
>
>
>
> set(CTEST_SITE $ENV{COMPUTERNAME})
>
> set(CTEST_BUILD_NAME $ENV{TEST_CASE_NAME})
>
>
>
> ctest_start()
>
>
>
> ctest_configure(RETURN_VALUE configure_failed)
>
>
>
> if($ENV{DO_UPDATE})
>
> ctest_update()
>
> endif($ENV{DO_UPDATE})
>
>
>
> if($ENV{DO_BUILD})
>
> ctest_build(RETURN_VALUE build_failed)
>
> endif($ENV{DO_BUILD})
>
>
>
> if (($ENV{DO_TEST}) AND NOT (configure_failed OR build_failed))
>
> ctest_test(RETURN_VALUE test_failed)
>
> endif(($ENV{DO_TEST}) AND NOT (configure_failed OR build_failed))
>
>
>
> if($ENV{DO_DASHBOARD})
>
> ctest_submit()
>
> endif($ENV{DO_DASHBOARD})
>
>
>
> if (configure_failed OR build_failed OR test_failed)
>
> message(FATAL_ERROR "Test ${CTEST_BUILD_NAME} failed.") # sets return
> value to -1
>
> endif(configure_failed OR build_failed OR test_failed)
>
>
>
> Best regards,
>
> Miroslav
>
>
>
> *From:* Muhammad Osama [mailto:osama94 at gmail.com]
> *Sent:* Monday, April 18, 2016 8:33 PM
> *To:* Matějů Miroslav, Ing.
> *Cc:* cmake at cmake.org
> *Subject:* Re: [CMake] CMakeLists.txt: How to print a message if ctest
> fails?
>
>
>
> Hi Miroslav,
>
>
>
> Thank you for replying! I added this in my root CMakeLists.txt, purposely
> made the ctest's test fail but didn't get the output message.
>
> Is this script suppose to be added inside CMakeLists.txt? Or am I doing
> this incorrectly?
>
>
>
> Thanks again,
>
>
>
> On Mon, Apr 18, 2016 at 6:30 AM, Matějů Miroslav, Ing. <
> Mateju.Miroslav at azd.cz> wrote:
>
> Hi Muhammad,
>
> you can use a CTest script, see
> https://cmake.org/Wiki/CMake_Scripting_Of_CTest for details. I use the
> following code in my CTest script:
>
>
>
> if(configure_failed OR build_failed OR test_failed)
>
> message(FATAL_ERROR "Test ${CTEST_BUILD_NAME} failed.")
>
> endif()
>
>
>
> Best regards,
>
> Miroslav
>
>
>
> *From:* CMake [mailto:cmake-bounces at cmake.org] *On Behalf Of *Muhammad
> Osama
> *Sent:* Friday, April 15, 2016 8:53 PM
> *To:* cmake at cmake.org
> *Subject:* [CMake] CMakeLists.txt: How to print a message if ctest fails?
>
>
>
> Is there a way I can setup CMakeLists.txt to print a message if ctest
> tests fail? For example:
>
> cmake ..
> make
> ctest // fails
> message output: Please contact xyz at mail.com to resolve testing problems.
>
> Note the message output is not for cmake but for ctest.
>
>
>
> --
>
> Muhammad
>
>
>
>
>
> --
>
> *Muhammad*
>
--
*Muhammad*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160419/29ef5b95/attachment.html>
More information about the CMake
mailing list