[CMake] packaging after success testing
Tyler Roscoe
tyler at cryptio.net
Fri Jan 7 12:15:31 EST 2011
On Fri, Jan 07, 2011 at 12:52:58PM +0100, ycollette.nospam at free.fr wrote:
> A while ago, a question similar to this one was posted, but no answer
> was given.
Link?
> Is it possible to perform the packaging part of a project only if the
> testing part has been successfully performed ?
I do this in the CTest script that drives dashboard builds. Not sure if
this is what you want as your question is so vague, but in case it
helps:
...
# Start a new submission.
ctest_start (${TP_DASHBOARD_MODEL})
# Calculate TP_CTEST_XML_DIR (which changes whenver ctest_start() is called).
file (READ "${CTEST_BINARY_DIRECTORY}/Testing/TAG" tag_file)
string (REGEX MATCH "[^\n]*" xml_dir ${tag_file})
set (TP_CTEST_XML_DIR "${CTEST_BINARY_DIRECTORY}/Testing/${xml_dir}")
...
# This section courtesy of Clinton Stimpson. It determines whether
# the tests passed or not. See
# http://permalink.gmane.org/gmane.comp.programming.tools.cmake.user/27268
# tests_result contains whether ctest was able to run tests, not
# whether any tests failed.
#
# This section mines the test results XML file generated by CTest and
# figures out if there were test failures. See also:
# http://public.kitware.com/Bug/view.php?id=8277
set (tests_passed 0)
if (tests_result MATCHES 0)
file (READ "${TP_CTEST_XML_DIR}/Test.xml" TEST_RESULTS)
string (REGEX MATCH "Status=\"[^p]" TestErrors "${TEST_RESULTS}")
if (TestErrors MATCHES "")
set (tests_passed 1)
endif ()
endif ()
...
if (tests_passed)
# Build and test succeeded, so build an install package and publish this build.
# Package. Append results to existing build.
if (TP_PACKAGE)
tp_build ("package" "APPEND")
else ()
message ("INFO: Packaging disabled.")
endif ()
[Stanza about publishing, aka copying build artifacts to the archive for later use, goes here using a similar pattern.]
...
hth,
tyler
More information about the CMake
mailing list