summaryrefslogtreecommitdiffstats
path: root/Tests/CPackTestAllGenerators/RunCPack.cmake
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2009-10-20 18:31:10 (GMT)
committerDavid Cole <david.cole@kitware.com>2009-10-20 18:31:10 (GMT)
commite1458ae4ab97a4ac668fd9153c6624e9e0e526b5 (patch)
tree13ce1429eaee8b4ebf62d986412d1165c938c5c3 /Tests/CPackTestAllGenerators/RunCPack.cmake
parent78174651b696a8e20ae55291a3b157bcab412408 (diff)
downloadCMake-e1458ae4ab97a4ac668fd9153c6624e9e0e526b5.zip
CMake-e1458ae4ab97a4ac668fd9153c6624e9e0e526b5.tar.gz
CMake-e1458ae4ab97a4ac668fd9153c6624e9e0e526b5.tar.bz2
Add test of all available CPack generators. Add this test with the goal of increasing coverage of the cpack source code, even/especially when the underlying packager tool is not installed. The test does not fail if there is a cpack problem with a certain generator. I expect some generators will fail on every machine running a CMake dashboard.
Diffstat (limited to 'Tests/CPackTestAllGenerators/RunCPack.cmake')
-rw-r--r--Tests/CPackTestAllGenerators/RunCPack.cmake55
1 files changed, 55 insertions, 0 deletions
diff --git a/Tests/CPackTestAllGenerators/RunCPack.cmake b/Tests/CPackTestAllGenerators/RunCPack.cmake
new file mode 100644
index 0000000..eb33ff4
--- /dev/null
+++ b/Tests/CPackTestAllGenerators/RunCPack.cmake
@@ -0,0 +1,55 @@
+if(NOT DEFINED cpack)
+ message(FATAL_ERROR "cpack not defined")
+endif()
+
+if(NOT DEFINED dir)
+ message(FATAL_ERROR "dir not defined")
+endif()
+
+# Analyze 'cpack --help' output for list of available generators:
+#
+execute_process(COMMAND ${cpack} --help
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE stdout
+ ERROR_VARIABLE stderr
+ WORKING_DIRECTORY ${dir})
+
+string(REPLACE ";" "\\;" stdout ${stdout})
+string(REPLACE "\n" "E;" stdout ${stdout})
+
+set(collecting 0)
+set(generators)
+foreach(eline ${stdout})
+ string(REGEX REPLACE "^(.*)E$" "\\1" line ${eline})
+ if(collecting AND NOT line STREQUAL "")
+ string(REGEX REPLACE "^ ([^ ]+) += (.*)$" "\\1" gen "${line}")
+ string(REGEX REPLACE "^ ([^ ]+) += (.*)$" "\\2" doc "${line}")
+ set(generators ${generators} ${gen})
+ endif()
+ if(line STREQUAL "Generators")
+ set(collecting 1)
+ endif()
+endforeach()
+
+# Call cpack with -G on each available generator. We do not care if this
+# succeeds or not. We expect it *not* to succeed if the underlying packaging
+# tools are not installed on the system... This test is here simply to add
+# coverage for the various cpack generators, even/especially to test ones
+# where the tools are not installed.
+#
+message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
+
+message(STATUS "CPack generators='${generators}'")
+
+foreach(g ${generators})
+ message(STATUS "Calling cpack -G ${g}...")
+ execute_process(COMMAND ${cpack} -G ${g}
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE stdout
+ ERROR_VARIABLE stderr
+ WORKING_DIRECTORY ${dir})
+ message(STATUS "result='${result}'")
+ message(STATUS "stdout='${stdout}'")
+ message(STATUS "stderr='${stderr}'")
+ message(STATUS "")
+endforeach()