Browse Source

Tests: Split RunCTest helper out of RunCMake.CTest(Submit|Memcheck)

Provide the "run_ctest" macro for use in other tests that also
want to cover running "ctest" scripts.
Brad King 10 years ago
parent
commit
9b50388b09

+ 2 - 14
Tests/RunCMake/CTestMemcheck/RunCMakeTest.cmake

@@ -1,23 +1,11 @@
-include(RunCMake)
+include(RunCTest)
 
 set(SITE test-site)
 set(BUILDNAME test-build)
 set(COVERAGE_COMMAND "")
 
 function(run_mc_test CASE_NAME CHECKER_COMMAND)
-  configure_file(${RunCMake_SOURCE_DIR}/test.cmake.in
-                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake @ONLY)
-  configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
-                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY)
-  configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
-                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/CMakeLists.txt @ONLY)
-  run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND}
-    -C Debug
-    -S ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake
-    -V
-    --output-log ${RunCMake_BINARY_DIR}/${CASE_NAME}-build/testOutput.log
-    ${ARGN}
-    )
+  run_ctest(${CASE_NAME} ${ARGN})
 endfunction()
 
 unset(CTEST_EXTRA_CONFIG)

+ 1 - 17
Tests/RunCMake/CTestSubmit/RunCMakeTest.cmake

@@ -1,26 +1,10 @@
-include(RunCMake)
+include(RunCTest)
 
 # Default case parameters.
 set(CASE_DROP_METHOD "http")
 set(CASE_DROP_SITE "-no-site-")
 set(CASE_CTEST_SUBMIT_ARGS "")
 
-function(run_ctest CASE_NAME)
-  configure_file(${RunCMake_SOURCE_DIR}/test.cmake.in
-                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake @ONLY)
-  configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
-                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY)
-  configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
-                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/CMakeLists.txt @ONLY)
-  run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND}
-    -C Debug
-    -S ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake
-    -V
-    --output-log ${RunCMake_BINARY_DIR}/${CASE_NAME}-build/testOutput.log
-    ${ARGN}
-    )
-endfunction()
-
 #-----------------------------------------------------------------------------
 # Test bad argument combinations.
 

+ 10 - 0
Tests/RunCMake/README.rst

@@ -22,6 +22,16 @@ but do not actually build anything.  To add a test:
 
    to fully customize the test case command-line.
 
+   Alternatively, if the test is to cover running ``ctest -S`` then use::
+
+    include(RunCTest)
+    run_ctest(SubTest1)
+    ...
+    run_ctest(SubTestN)
+
+   and create ``test.cmake.in``, ``CTestConfig.cmake.in``, and
+   ``CMakeLists.txt.in`` files to be configured for each case.
+
 4. Create file ``<Test>/CMakeLists.txt`` in the directory containing::
 
     cmake_minimum_required(...)

+ 17 - 0
Tests/RunCMake/RunCTest.cmake

@@ -0,0 +1,17 @@
+include(RunCMake)
+
+function(run_ctest CASE_NAME)
+  configure_file(${RunCMake_SOURCE_DIR}/test.cmake.in
+                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake @ONLY)
+  configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
+                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY)
+  configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
+                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/CMakeLists.txt @ONLY)
+  run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND}
+    -C Debug
+    -S ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake
+    -V
+    --output-log ${RunCMake_BINARY_DIR}/${CASE_NAME}-build/testOutput.log
+    ${ARGN}
+    )
+endfunction()