]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improve the test script
authorMatthias Maier <tamiko@kyomu.43-1.org>
Thu, 19 Sep 2013 16:41:34 +0000 (16:41 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Thu, 19 Sep 2013 16:41:34 +0000 (16:41 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@30833 0785d39b-7218-0410-832d-ea1e28bc413d

tests/run_testsuite.cmake

index f82db335730d0762f9ac95664e2ba68681e3c3fb..82f1bf5f45e24f0daacdf396bd43fdf381c5076b 100644 (file)
@@ -14,6 +14,7 @@
 ##
 ## ---------------------------------------------------------------------
 
+
 ########################################################################
 #                                                                      #
 #                             Test setup:                              #
 ########################################################################
 
 #
-# Configuration options:
+# This is the test script for running the testsuite.
+#
+# Invoke it in a _build directory_ (or designated build directory) via:
+#
+#   ctest -S <...>/run_testsuite.cmake
+#
+# The following configuration variables can be overriden with
+#
+#   ctest -D<variable>=<value> [...]
+#
+#
+#   CTEST_SOURCE_DIRECTORY
+#     - The source directory of deal.II (usually ending in "[...]/deal.II"
+#       (equivalent to https://svn.dealii.org/trunk/deal.II)
+#       Note: This is _not_ the test directory ending in "[...]/tests"
+#     - If unspecified, "../deal.II" relative to the location of this
+#       script is used. If this is not a source directory, an error is
+#       thrown.
 #
-# CTEST_SOURCE_DIRECTORY
-# CTEST_BINARY_DIRECTORY
-# CTEST_CMAKE_GENERATOR
+#   CTEST_BINARY_DIRECTORY
+#     - The designated build directory (already configured, empty, or non
+#       existent - see the information about TRACKs what will happen)
+#     - If unspecified the current directory is used. If the current
+#       directory is equal to CTEST_SOURCE_DIRECTORY or the "tests"
+#       directory, an error is thrown.
 #
-# TRACK
+#   CTEST_CMAKE_GENERATOR
+#     - The CMake Generator to use (e.g. "Unix Makefiles", or "Ninja", see
+#       $ man cmake)
+#     - If unspecified the generator of a configured build directory will
+#       be used. If this information is not available, an error is thrown.
 #
-# NO_JOBS
-# CONFIG_FILE
+#   TRACK
+#     - TODO (defaults to "Experimental")
 #
-# TEST_DIFF
-# TEST_TIME_LIMIT
-# TEST_PICKUP_REGEX
-# NUMDIFF_DIR
+#   NO_JOBS
+#     - The number of concurrent build and test jobs (defaults to 1).
 #
+#   CONFIG_FILE
+#     - A configuration file (see ../deal.II/docs/development/Config.sample)
+#       that will be used during the configuration stage (invokes
+#       # cmake -C ${CONFIG_FILE}). This only has an effect if
+#       CTEST_BINARY_DIRECTORY is empty.
 #
+# Furthermore, the following variables controlling the testsuite can be set
+# and will be automatically handed down to cmake:
+#
+#   TEST_DIFF
+#   TEST_TIME_LIMIT
+#   TEST_PICKUP_REGEX
+#   NUMDIFF_DIR
+#
+# For details, consult the ./README file.
+#
+
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
 MESSAGE("-- This is CTest ${CTEST_VERSION}")
 
 #
-# CTEST_SOURCE_DIR:
+# TRACK: Default to Experimental:
+#
+
+IF("${TRACK}" STREQUAL "")
+  SET(TRACK "Experimental")
+ENDIF()
+
+IF( NOT "${TRACK}" STREQUAL "Experimental"
+    AND NOT "${TRACK}" STREQUAL "Build Tests" )
+  MESSAGE(FATAL_ERROR "TODO: Unknown TRACK \"${TRACK}\"")
+ENDIF()
+
+MESSAGE("-- TRACK:                  ${TRACK}")
+
+#
+# CTEST_SOURCE_DIRECTORY:
 #
 
 IF("${CTEST_SOURCE_DIRECTORY}" STREQUAL "")
@@ -69,25 +123,37 @@ ENDIF()
 MESSAGE("-- CTEST_SOURCE_DIRECTORY: ${CTEST_SOURCE_DIRECTORY}")
 
 #
-# CTEST_BINARY_DIR:
+# CTEST_BINARY_DIRECTORY:
 #
 
 IF("${CTEST_BINARY_DIRECTORY}" STREQUAL "")
   #
   # If CTEST_BINARY_DIRECTORY is not set we just use the current directory
-  # except it is equal to CTEST_SOURCE_DIRECTORY in which case we fail.
+  # except if it is equal to CTEST_SOURCE_DIRECTORY in which case we fail.
   #
   SET(CTEST_BINARY_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
 
-  IF("${CTEST_BINARY_DIRECTORY}" STREQUAL "${CTEST_SOURCE_DIR}")
+  IF( "${CTEST_BINARY_DIRECTORY}" STREQUAL "${CTEST_SOURCE_DIR}"
+      OR "${CTEST_BINARY_DIRECTORY}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}" )
     MESSAGE(FATAL_ERROR "
-ctest was invoked in the source directory and CTEST_BINARY_DIRECTORY is not set.
+ctest was invoked in the source directory (or test source directory) and CTEST_BINARY_DIRECTORY is not set.
 Please either call ctest from within a designated build directory, or set CTEST_BINARY_DIRECTORY accordingly.
 "
       )
   ENDIF()
 ENDIF()
 
+# Make sure that for a build test the directory is empty:
+FILE(GLOB _test ${CTEST_BINARY_DIRECTORY}/*)
+IF( "${TRACK}" STREQUAL "Build Tests"
+    AND NOT "${_test}" STREQUAL "" )
+    MESSAGE(FATAL_ERROR "
+TRACK was set to \"Build Tests\" which require an empty build directory.
+But files werer found in \"${CTEST_BINARY_DIRECTORY}\"
+"
+      )
+ENDIF()
+
 MESSAGE("-- CTEST_BINARY_DIRECTORY: ${CTEST_BINARY_DIRECTORY}")
 
 #
@@ -126,14 +192,15 @@ CTEST_CMAKE_GENERATOR was set to a different Generator \"${CTEST_CMAKE_GENERATOR
 ENDIF()
 
 #
-# NO_JOBS:
+# CTEST_UPDATE_COMMAND:
 #
 
-IF("${NO_JOBS}" STREQUAL "")
-  SET(NO_JOBS "1")
+FIND_PACKAGE(Subversion QUIET)
+IF(SUBVERSION_FOUND)
+  SET(CTEST_UPDATE_COMMAND ${Subversion_SVN_EXECUTABLE})
 ENDIF()
 
-MESSAGE("-- NO_JOBS: ${NO_JOBS}")
+MESSAGE("-- CTEST_UPDATE_COMMAND:   ${CTEST_UPDATE_COMMAND}")
 
 #
 # CTEST_SITE:
@@ -143,24 +210,55 @@ FIND_PROGRAM(HOSTNAME_COMMAND NAMES hostname)
 EXEC_PROGRAM(${HOSTNAME_COMMAND} OUTPUT_VARIABLE _hostname)
 SET(CTEST_SITE "${_hostname}")
 
+MESSAGE("-- CTEST_SITE:             ${CTEST_SITE}")
+
 #
-# CTEST_UPDATE_COMMAND
+# Assemble configuration options, we need it now:
 #
 
-FIND_PACKAGE(Subversion QUIET)
-IF(SUBVERSION_FOUND)
-  SET(CTEST_UPDATE_COMMAND ${Subversion_SVN_EXECUTABLE})
+IF(NOT "${CONFIG_FILE}" STREQUAL "")
+  SET(_options "-C${CONFIG_FILE}")
 ENDIF()
 
+# Pass all relevant "TEST_" variables down to configure:
+GET_CMAKE_PROPERTY(_variables VARIABLES)
+FOREACH(_var ${_variables})
+  IF(_var MATCHES
+      "^(TEST_DIFF|TEST_TIME_LIMIT|TEST_PICKUP_REGEX|NUMDIFF_DIR)$"
+      )
+    LIST(APPEND _options "-D${_var}=${${_var}}")
+  ENDIF()
+ENDFOREACH()
+
 #
-# CTEST_BUILD_NAME
+# CTEST_BUILD_NAME:
 #
 
 SET(CTEST_BUILD_NAME
   "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}"
   )
 
-# Append compiler information if available...
+#
+# Append compiler information to CTEST_BUILD_NAME:
+#
+
+IF(NOT EXISTS ${CTEST_BINARY_DIRECTORY}/detailed.log)
+  # Apparently, ${CTEST_BINARY_DIRECTORY} is not a configured build
+  # directory. In this case we need a trick: set up a dummy project and
+  # query it for the compiler information.
+  FILE(WRITE ${CTEST_BINARY_DIRECTORY}/query_for_compiler/CMakeLists.txt "
+FILE(WRITE ${CTEST_BINARY_DIRECTORY}/detailed.log
+  \"#        CMAKE_CXX_COMPILER:     \${CMAKE_CXX_COMPILER_ID} \${CMAKE_CXX_COMPILER_VERSION} on platform \${CMAKE_SYSTEM_NAME} \${CMAKE_SYSTEM_PROCESSOR}\"
+  )"
+    )
+  EXECUTE_PROCESS(
+    COMMAND ${CMAKE_COMMAND} ${_options} "-G${CTEST_CMAKE_GENERATOR}" .
+    OUTPUT_QUIET ERROR_QUIET
+    WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY}/query_for_compiler
+    )
+  FILE(REMOVE_RECURSE ${CTEST_BINARY_DIRECTORY}/query_for_compiler)
+ENDIF()
+
 IF(EXISTS ${CTEST_BINARY_DIRECTORY}/detailed.log)
   FILE(STRINGS ${CTEST_BINARY_DIRECTORY}/detailed.log _compiler_id
     REGEX "CMAKE_CXX_COMPILER:"
@@ -176,24 +274,64 @@ IF(EXISTS ${CTEST_BINARY_DIRECTORY}/detailed.log)
   ENDIF()
 ENDIF()
 
-IF(NOT TRACK MATCHES "Foobar") #TODO: Exclude Continuous TRACKS
-  #Append subversion revision:
-  IF(SUBVERSION_FOUND)
-    EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info
-      ${CTEST_SOURCE_DIRECTORY} RESULT_VARIABLE _result
-      )
-    IF(${_result} EQUAL 0)
-      Subversion_WC_INFO(${CTEST_SOURCE_DIRECTORY} _svn)
-      STRING(REGEX REPLACE "^${_svn_WC_ROOT}/" "" _branch ${_svn_WC_URL})
-      STRING(REGEX REPLACE "^branches/" "" _branch ${_branch})
-      STRING(REGEX REPLACE "/deal.II$" "" _branch ${_branch})
-      SET(CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-${_branch}-r${_svn_WC_REVISION}")
-    ENDIF()
+#
+# Append subversion information to CTEST_BUILD_NAME:
+#
+
+IF(NOT TRACK MATCHES "Foobar" AND SUBVERSION_FOUND) #TODO: Exclude Continuous TRACKS
+  EXECUTE_PROCESS(
+    COMMAND ${Subversion_SVN_EXECUTABLE} info ${CTEST_SOURCE_DIRECTORY}
+    OUTPUT_QUIET ERROR_QUIET
+    RESULT_VARIABLE _result
+    )
+  IF(${_result} EQUAL 0)
+    Subversion_WC_INFO(${CTEST_SOURCE_DIRECTORY} _svn)
+    STRING(REGEX REPLACE "^${_svn_WC_ROOT}/" "" _branch ${_svn_WC_URL})
+    STRING(REGEX REPLACE "^branches/" "" _branch ${_branch})
+    STRING(REGEX REPLACE "/deal.II$" "" _branch ${_branch})
+    SET(CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-${_branch}-r${_svn_WC_REVISION}")
   ENDIF()
 ENDIF()
 
+MESSAGE("-- CTEST_BUILD_NAME:       ${CTEST_BUILD_NAME}")
+
+#
+# Write revision log:
+#
+
+IF(DEFINED _svn_WC_REVISION)
+  FILE(WRITE ${CTEST_BINARY_DIRECTORY}/revision.log
+"###
+#
+#  SVN information:
+#        SVN_WC_URL:               ${SVN_WC_URL}
+#        SVN_WC_REVISION:          ${_svn_WC_REVISION}
+#        SVN_WC_LAST_CHANGED_DATE: ${_svn_WC_LAST_CHANGED_DATE}
 #
-# Finalize:
+###"
+    )
+ELSE()
+  FILE(WRITE ${CTEST_BINARY_DIRECTORY}/revision.log
+"###
+#
+#  No SVN information available.
+#
+###"
+    )
+ENDIF()
+
+#
+# NO_JOBS:
+#
+
+IF("${NO_JOBS}" STREQUAL "")
+  SET(NO_JOBS "1")
+ENDIF()
+
+MESSAGE("-- NO_JOBS:                ${NO_JOBS}")
+
+#
+# Declare files that should be submitted as notes:
 #
 
 SET(CTEST_NOTES_FILES
@@ -202,19 +340,6 @@ SET(CTEST_NOTES_FILES
   ${CTEST_BINARY_DIRECTORY}/detailed.log
   )
 
-IF(NOT "${CONFIG_FILE}" STREQUAL "")
-  SET(_options "-C${CONFIG_FILE}")
-ENDIF()
-
-# Pass all relevant "TEST_" variables down to configure:
-GET_CMAKE_PROPERTY(_variables VARIABLES)
-FOREACH(_var ${_variables})
-  IF(_var MATCHES
-      "^(TEST_DIFF|TEST_TIME_LIMIT|TEST_PICKUP_REGEX|NUMDIFF_DIR)$"
-      )
-    LIST(APPEND _options "-D${_var}=${${_var}}")
-  ENDIF()
-ENDFOREACH()
 
 ########################################################################
 #                                                                      #
@@ -222,36 +347,17 @@ ENDFOREACH()
 #                                                                      #
 ########################################################################
 
-IF("${TRACK}" STREQUAL "Experimental")
-
-  #
-  # TRACK Experimental:
-  #
-  # It is assumed that the build directory is already configured
-  #
-  # - Run the configure, build and test stages and submit the results to
-  #   the "Experimental" track
-  #
-  # - No cleanup is done
-  #
-
-  CTEST_START(Experimental TRACK Experimental)
+CTEST_START(Experimental TRACK ${TRACK})
 
-  CTEST_CONFIGURE(OPTIONS "${_options}")
+CTEST_CONFIGURE(OPTIONS "${_options}")
 
-  CTEST_BUILD(TARGET) # run all target
+CTEST_BUILD(TARGET) # run all target
 
-  # TODO: Run this during the BUILD stage...
-  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND}
-    --build ${CTEST_BINARY_DIRECTORY} --target setup_test
-    )
-
-  CTEST_TEST(PARALLEL_LEVEL ${NO_JOBS})
-
-  CTEST_SUBMIT()
-
-ELSE()
+# TODO: Run this during the BUILD stage...
+EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND}
+  --build ${CTEST_BINARY_DIRECTORY} --target setup_test
+  )
 
-  MESSAGE(FATAL_ERROR "TRACK has to be set TODO")
+CTEST_TEST(PARALLEL_LEVEL ${NO_JOBS})
 
-ENDIF()
+CTEST_SUBMIT()

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.