Add messages for skipped tests in make check
authorTeemu Murtola <teemu.murtola@gmail.com>
Sun, 5 Jan 2014 05:45:46 +0000 (07:45 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 9 Jan 2014 05:51:08 +0000 (06:51 +0100)
Make 'make check' print a message if unit tests and/or regression tests
are not run, and instruct the user how to change that.

While at it, clean up the test CMake setup slightly. Move some target
definitions into a different file or a different place to make the CMake
code easier to follow, and remove an unnecessary test for CMake version
now that we require 2.8.8.

It is difficult to produce such a message in 'make test', so hopefully
the higher-level message is sufficient.

Change-Id: I8283c88ffab1d797676ba83880690d465ac195ff

CMakeLists.txt
src/CMakeLists.txt
tests/CMakeLists.txt

index fc28eb098e6fe18d6190a432617b5a8d71588466..35ead9fd7bd301340713103f8de18d19c0b54b74 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2009,2010,2011,2012,2013, by the GROMACS development team, led by
+# Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -956,6 +956,21 @@ if (GMX_BUILD_FOR_COVERAGE)
     add_definitions(-DNDEBUG -DBOOST_DISABLE_ASSERTS -DGMX_DISABLE_ASSERTS)
 endif ()
 
+if (BUILD_TESTING)
+    # "tests" target builds all the separate test binaries.
+    add_custom_target(tests)
+    # "run-ctest" is an internal target that actually runs the tests.
+    # This is necessary to be able to add separate targets that execute as part
+    # of 'make check', but are ensured to be executed after the actual tests.
+    add_custom_target(run-ctest
+                      COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
+                      COMMENT "Running all tests"
+                      VERBATIM)
+    add_dependencies(run-ctest tests)
+    # "check" target builds and runs all tests.
+    add_custom_target(check DEPENDS run-ctest)
+endif()
+
 if (NOT GMX_BUILD_MDRUN_ONLY)
     add_subdirectory(doxygen)
     add_subdirectory(share)
@@ -963,6 +978,10 @@ if (NOT GMX_BUILD_MDRUN_ONLY)
 endif ()
 add_subdirectory(src)
 
+if (BUILD_TESTING)
+    add_subdirectory(tests)
+endif()
+
 # Issue a warning if NVIDIA GPUs were detected, but CUDA was not found.
 # Don't bother the user after the first configure pass.
 if ((CUDA_NOTFOUND_AUTO AND GMX_DETECT_GPU_AVAILABLE) AND NOT GMX_GPU_DETECTION_DONE)
@@ -983,25 +1002,6 @@ ADD_CUSTOM_TARGET(uninstall
                   "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
 ###########################
 
-########################################################################
-# Tests                                                                #
-########################################################################
-
-IF(BUILD_TESTING)
-    enable_testing()
-    #"check" target builds and runs all tests
-    add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
-    add_dependencies(check tests)
-    # TODO: This would be better within tests/CMakeLists.txt
-    if (NOT GMX_BUILD_MDRUN_ONLY)
-        #gmxtests target builds all binaries required for running gmxtest
-        add_custom_target(gmxtests DEPENDS gmx links)
-        add_dependencies(check gmxtests)
-        add_subdirectory(tests)
-    endif()
-    #TODO: Add warning if NOT REGRESSIONTEST_PATH OR NOT GMX_XML that regression/unit tests are not run.
-ENDIF()
-
 ########################################################################
 # Manual                                                               #
 ########################################################################
index 2346c9d2c9829be6b712a8de06ea048b6310a71c..caa02b92b5b715979866270df1537329f5e1819c 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2009,2010,2011,2012,2013, by the GROMACS development team, led by
+# Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -46,15 +46,20 @@ configure_file(config.h.cmakein config.h)
 configure_file(buildinfo.h.cmakein buildinfo.h ESCAPE_QUOTES)
 
 if (BUILD_TESTING)
-    add_custom_target(tests)
     if (GMX_BUILD_UNITTESTS)
         add_subdirectory(external/gmock-1.7.0)
-    endif (GMX_BUILD_UNITTESTS)
+    endif()
     include(testutils/TestMacros.cmake)
     if (GMX_BUILD_UNITTESTS)
         add_subdirectory(testutils)
-    endif (GMX_BUILD_UNITTESTS)
-endif (BUILD_TESTING)
+    else()
+        add_custom_target(unittests-notice
+            ${CMAKE_COMMAND} -E echo "NOTE: Unit tests have not been run. You need to set GMX_BUILD_UNITTESTS=ON if you want to build and run them."
+            DEPENDS run-ctest
+            COMMENT "Unit tests disabled" VERBATIM)
+        add_dependencies(check unittests-notice)
+    endif()
+endif()
 
 add_subdirectory(gromacs)
 add_subdirectory(programs)
index 5ccc4075b8d0c6d90caaa75f775bd2f44816f42c..f7bb023229fee39d4cdf2cacb9812053a9cc74a5 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
 set(REGRESSIONTEST_PATH "" CACHE PATH "Directory containing regressiontests")
 mark_as_advanced(REGRESSIONTEST_PATH)
 option(REGRESSIONTEST_DOWNLOAD
-    "Automatically download regressiontests. Tests can be run with ctest." no)
-if(REGRESSIONTEST_DOWNLOAD AND CMAKE_VERSION VERSION_LESS "2.8.2")
-    message(WARNING "REGRESSIONTEST_DOWNLOAD requires cmake >=2.8.2. Please update cmake or manually download the regressiontests.")
-    set(REGRESSIONTEST_DOWNLOAD FALSE CACHE BOOL 
-        "REGRESSIONTEST_DOWNLOAD not supported with cmake ${CMAKE_VERSION}" FORCE)
-endif()
+    "Automatically download regressiontests. Tests can be run with ctest." OFF)
+
 if(REGRESSIONTEST_DOWNLOAD)
     if("${PROJECT_VERSION}" MATCHES "-dev")
        if("${PROJECT_VERSION}" MATCHES "^5[.]")
@@ -81,11 +77,14 @@ log: ${log}")
     set(REGRESSIONTEST_DOWNLOAD OFF CACHE BOOL "Tests already downloaded. Set to yes to download again" FORCE)
 endif()
 
-if(REGRESSIONTEST_PATH AND (GMX_BLUEGENE OR CMAKE_CROSSCOMPILING OR CMAKE_CONFIGURATION_TYPES))
-    #Bluegene requires us to compile both front-end and back-end binaries (single build is insufficient)
-    message(WARNING 
-        "With cross-compiling or multi-configuration generators (e.g. Visual Studio), running regressiontests from build system is not supported. Please run gmxtest.pl directly.")
-    set(REGRESSIONTEST_PATH OFF CACHE BOOL 
+if(REGRESSIONTEST_PATH AND (GMX_BLUEGENE OR CMAKE_CROSSCOMPILING OR CMAKE_CONFIGURATION_TYPES OR GMX_BUILD_MDRUN_ONLY))
+    # TODO: It would be nicer to do these before potentially downloading the tests.
+    # Bluegene requires us to compile both front-end and back-end binaries
+    # (single build is insufficient)
+    # Testing an mdrun-only builds require supporting binaries from a full build
+    message(WARNING
+        "With cross-compiling, multi-configuration generators (e.g. Visual Studio), or with mdrun-only builds, running regressiontests from build system is not supported. Please run gmxtest.pl directly.")
+    set(REGRESSIONTEST_PATH OFF CACHE BOOL
         "With cross-compiling or multi-configuration generators, running regressiontests from build system is not supported." FORCE)
 endif()
 
@@ -94,6 +93,11 @@ if(REGRESSIONTEST_PATH)
         message(FATAL_ERROR
             "REGRESSIONTEST_PATH invalid. The path needs to contain gmxtest.pl.")
     endif()
+
+    # gmxtests target builds all binaries required for running gmxtest
+    add_custom_target(gmxtests DEPENDS gmx)
+    add_dependencies(check gmxtests)
+
     if(GMX_DOUBLE)
         list(APPEND ARGS -double)
     endif()
@@ -159,6 +163,12 @@ if(REGRESSIONTEST_PATH)
         set_tests_properties(regressiontests/${subtest} PROPERTIES
             ENVIRONMENT "PATH=${PATH}")
     endforeach()
+else()
+    add_custom_target(regressiontests-notice
+        ${CMAKE_COMMAND} -E echo "NOTE: Regression tests have not been run. If you want to run them from the build system, get the correct version of the regression tests package and set REGRESSIONTEST_PATH in CMake to point to it, or set REGRESSIONTEST_DOWNLOAD=ON."
+        DEPENDS run-ctest
+        COMMENT "Regression tests not available" VERBATIM)
+    add_dependencies(check regressiontests-notice)
 endif()
 
 include(CppCheck.cmake)