From 152817d244f3fad7ef692da06a01c06d80329495 Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.r.kempf@gmail.com> Date: Thu, 15 Oct 2015 19:00:15 +0200 Subject: [PATCH] Implement dune_add_test and port dune-common --- cmake/modules/DuneMacros.cmake | 12 +- cmake/modules/DuneTestMacros.cmake | 217 +++++++++++--- cmake/modules/DuneTests.cmake | 19 -- dune/common/CMakeLists.txt | 2 +- dune/common/parallel/CMakeLists.txt | 2 +- dune/common/parallel/test/CMakeLists.txt | 5 - dune/common/test/CMakeLists.txt | 355 ++++++++++------------- 7 files changed, 326 insertions(+), 286 deletions(-) delete mode 100644 cmake/modules/DuneTests.cmake diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake index a2c55b011..2765fa506 100644 --- a/cmake/modules/DuneMacros.cmake +++ b/cmake/modules/DuneMacros.cmake @@ -121,8 +121,8 @@ enable_language(C) # Enable C to skip CXX bindings for some tests. include(FeatureSummary) include(DuneEnableAllPackages) +include(DuneTestMacros) include(OverloadCompilerFlags) - include(DuneSymlinkOrCopy) # Converts a module name given by _module into an uppercase string @@ -687,11 +687,6 @@ macro(dune_project) # building them before. include(DuneDoc) - # activate testing the DUNE way - include(DuneTests) - # enable this way of testing by default - set(DUNE_TEST_MAGIC ON) - # activate pkg-config include(DunePkgConfig) @@ -919,11 +914,6 @@ endif() configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) endif("${ARGC}" EQUAL "1") - # add dependiencies to target "test" - if(DUNE_TEST_MAGIC) - test_dep() - endif() - include(CPack) feature_summary(WHAT ALL) diff --git a/cmake/modules/DuneTestMacros.cmake b/cmake/modules/DuneTestMacros.cmake index 732f998d0..17e2dcd05 100644 --- a/cmake/modules/DuneTestMacros.cmake +++ b/cmake/modules/DuneTestMacros.cmake @@ -1,56 +1,185 @@ -# Module provides macros that allow for on demand test building. -# In DUNE tests are not built by make all but by make test. +# Module that provides tools for testing the Dune way. # -# Provides the following macros: +# Note that "the Dune way" of doing this has changed after +# the 2.4 release. See the buildsystem documentation for details. # -# test_dep() +# .. cmake_function:: dune_add_test # -# Finds all directories called test and creates a dependency for -# testing that calls builds the tests for this directory. +# .. cmake_brief:: # +# Adds a test to the Dune testing suite! # -# add_directory_test_target(_target) +# .. cmake_param:: NAME +# :single: # -# Creates a custom target for building -# the tests in the current directory. +# The name of the test that should be added. If an executable +# is also added (by specifying SOURCES), the executable is also +# named accordingly. If omitted, the name will be deduced from +# the (single) sources parameter or from the given target. Note, +# that this requires you to take care, that you only use a target +# or source file for but one such test. # -# The target name will be the path of the -# current directory relative to ${CMAKE_BINARY_DIR} -# with all slashes replaced by underlines. -# E.g. for dune/istl/test the target will be dune_istl_test. +# .. cmake_param:: SOURCES +# :multi: # -macro(test_dep) - dune_common_script_dir(SCRIPT_DIR) - get_filename_component(RELPATH "${CMAKE_SOURCE_DIR}" REALPATH) - execute_process(COMMAND ${CMAKE_COMMAND} -D RELPATH=${RELPATH} -P ${SCRIPT_DIR}/FindFiles.cmake - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE _res ERROR_VARIABLE _dirs) - - foreach(_dir ${_dirs}) - string(REGEX REPLACE "([^ \t\n]+)[ \n\t]*$" "\\1" _dir ${_dir}) - set_property(DIRECTORY ${_dir} PROPERTY TEST_INCLUDE_FILE ${CMAKE_BINARY_DIR}/${_dir}/BuildTests.cmake) - endforeach(_dir ${_dirs}) -endmacro(test_dep) - -macro(get_directory_test_target _target _dir) - string(REPLACE "${CMAKE_BINARY_DIR}" "" _relative_dir "${_dir}") - string(REPLACE "/" "_" ${_target} "${_relative_dir}") -endmacro(get_directory_test_target _target _dir) - +# The source files that this test depends on. These are the +# sources that will be passed to :ref:`add_executable`. +# +# You *must* specify either :code:`SOURCES` or :code:`TARGET`. +# +# .. cmake_param:: TARGET +# :single: +# +# An executable target which should be used for the test. Use +# this option over the :code:`SOURCES` parameter if you want to +# reuse already added targets. +# +# You *must* specify either :code:`SOURCES` or :code:`TARGET`. +# +# .. cmake_param:: COMPILE_DEFINITIONS +# :multi: +# +# A set of compile definitions to add to the target. +# Only definitions beyond the application of :ref:`add_dune_all_flags` +# have to be stated. +# This is only used, if :code:`dune_add_test` adds the executable itself. +# +# .. cmake_param:: COMPILE_FLAGS +# :multi: +# +# A set of non-definition compile flags to add to the target. +# Only flags beyond the application of :ref:`add_dune_all_flags` +# have to be stated. +# This is only used, if :code:`dune_add_test` adds the executable itself. # -# - Create a custom target for building -# the tests in the current directory. +# .. cmake_param:: LINK_LIBRARIES +# :multi: # -# The target name will be the path of the -# current directory relative to ${CMAKE_BINARY_DIR} -# with all slashes replaced by underlines. -# E.g. for dune/istl/test the target will be dune_istl_test. +# A list of libraries to link the target to. +# Only libraries beyond the application of :ref:`add_dune_all_flags` +# have to be stated. +# This is only used, if :code:`dune_add_test` adds the executable itself. # -macro(add_directory_test_target _target) - if(DUNE_TEST_MAGIC) - get_directory_test_target(${_target} "${CMAKE_CURRENT_BINARY_DIR}") - add_custom_target(${${_target}}) - dune_common_script_dir(SCRIPT_DIR) - configure_file(${SCRIPT_DIR}/BuildTests.cmake.in BuildTests.cmake @ONLY) +# .. cmake_param:: EXPECT_COMPILE_FAIL +# :option: +# +# If given, the test is expected to not compile successfully! +# +# .. cmake_param:: EXPECT_FAIL +# :option: +# +# If given, this test is expected to compile, but fail to run. +# +# .. cmake_param:: SKIP_ON_77 +# +# The test will be marked as skipped in ctest if it returned 77. +# +# This function defines the Dune way of adding a test to the testing suite. +# You may either add the executable yourself through :ref:`add_executable` +# and pass it to the :code:`TARGET` option, or you may rely on :ref:`dune_add_test` +# to do so. +# +# .. cmake_variable:: REENABLE_ADD_TEST +# +# You may set this variable to True either through your opts file or in your module +# (before the call to :code:`include(DuneMacros)`) to suppress the error that is thrown if +# :code:`add_test` is used. You should only do that if you have proper reason to do so. +# + +# enable the testing suite on the CMake side. +enable_testing() +include(CTest) + +# Introduce a target that triggers the building of all tests +add_custom_target(build_tests) + +function(dune_add_test) + include(CMakeParseArguments) + set(OPTIONS EXPECT_COMPILE_FAIL EXPECT_FAIL SKIP_ON_77) + set(SINGLEARGS NAME TARGET) + set(MULTIARGS SOURCES COMPILE_DEFINITIONS COMPILE_FLAGS LINK_LIBRARIES) + cmake_parse_arguments(ADDTEST "${OPTIONS}" "${SINGLEARGS}" "${MULTIARGS}" ${ARGN}) + + # Check whether the parser produced any errors + if(ADDTEST_UNPARSED_ARGUMENTS) + message(WARNING "Unrecognized arguments ('${ADDTEST_UNPARSED_ARGUMENTS}') for dune_add_test!") + endif() + + # Check input for validity and apply defaults + if(NOT ADDTEST_SOURCES AND NOT ADDTEST_TARGET) + message(FATAL_ERROR "You need to specify either the SOURCES or the TARGET option for dune_add_test!") + endif() + if(ADDTEST_SOURCES AND ADDTEST_TARGET) + message(FATAL_ERROR "You cannot specify both SOURCES and TARGET for dune_add_test") + endif() + if(NOT ADDTEST_NAME) + # try deducing the test name from the executable name + if(ADDTEST_TARGET) + set(ADDTEST_NAME ${ADDTEST_TARGET}) + endif() + # try deducing the test name form the source name + if(ADDTEST_SOURCES) + # deducing a name is only possible with a single source argument + list(LENGTH ADDTEST_SOURCES len) + if(NOT len STREQUAL "1") + message(FATAL_ERROR "Cannot deduce test name from multiple sources!") + endif() + # strip file extension + get_filename_component(ADDTEST_NAME ${ADDTEST_SOURCES} NAME_WE) + endif() + endif() + + # Add the executable if it is not already present + if(ADDTEST_SOURCES) + add_executable(${ADDTEST_NAME} ${ADDTEST_SOURCES}) + # add all flags to the target! + add_dune_all_flags(${ADDTEST_NAME}) + # This is just a placeholder + target_compile_definitions(${ADDTEST_NAME} PUBLIC ${ADDTEST_COMPILE_DEFINITIONS}) + target_compile_options(${ADDTEST_NAME} PUBLIC ${ADDTEST_COMPILE_FLAGS}) + target_link_libraries(${ADDTEST_NAME} ${ADDTEST_LINK_LIBRARIES}) + set(ADDTEST_TARGET ${ADDTEST_NAME}) + endif() + + # Make sure to exclude the target from all, even when it is user-provided + set_property(TARGET ${ADDTEST_TARGET} PROPERTY EXCLUDE_FROM_ALL 1) + + # Have the given target depend on build_tests in order to trigger the build correctly + if(NOT ADDTEST_EXPECT_COMPILE_FAIL) + add_dependencies(build_tests ${ADDTEST_TARGET}) + endif() + + # By default, the target itself is sufficient as a testing command. + set(TESTCOMMAND ${ADDTEST_TARGET}) + + # Process the EXPECT_COMPILE_FAIL option + if(ADDTEST_EXPECT_COMPILE_FAIL) + set(TESTCOMMAND ${CMAKE_COMMAND} --build . --target ${TESTCOMMAND} --config $<CONFIGURATION>) + endif() + + # Now add the actual test + _add_test(NAME ${ADDTEST_NAME} + COMMAND ${TESTCOMMAND} + ) + + # Process the EXPECT_FAIL option + if(ADDTEST_EXPECT_COMPILE_FAIL OR ADDTEST_EXPECT_FAIL) + set_tests_properties(${ADDTEST_NAME} PROPERTIES WILL_FAIL true) + endif() + # Process the SKIP_ON_77 option + if(ADDTEST_SKIP_ON_77) + set_tests_properties(${ADDTEST_NAME} PROPERTIES SKIP_RETURN_CODE 77) + endif() +endfunction() + +macro(add_directory_test_target) + message(FATAL_ERROR "The function add_directory_test_target has been removed alongside all testing magic in dune-common. Check dune_add_test for the new way!") +endmacro() + +macro(add_test) + if(NOT REENABLE_ADD_TEST) + message(SEND_ERROR "Please dune_add_test instead of add_test! If you need add_test in a downstream project, set the variable REENABLE_ADD_TEST to True in that project to suppress this error.") + else() + _add_test(${ARGN}) endif() -endmacro(add_directory_test_target) +endmacro() diff --git a/cmake/modules/DuneTests.cmake b/cmake/modules/DuneTests.cmake deleted file mode 100644 index f711f7a8b..000000000 --- a/cmake/modules/DuneTests.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# Create a custom target for building the tests. -# Thus they will not be built by make all any more. -# Actually I wanted this target to be a dependency -# of make test but that is currently not possible. -# See http://public.kitware.com/Bug/view.php?id=8438 -# This really sucks! -# Therefore currently make build_tests has to be called -# before make test. - -# enable testing before adding the subdirectories. -# Thus we can add the tests in the subdirectories -# where they actually are. -enable_testing() - -#activate CTest -include(CTest) - -#include our macros -include(DuneTestMacros) diff --git a/dune/common/CMakeLists.txt b/dune/common/CMakeLists.txt index df3d53eb0..71a9e3a05 100644 --- a/dune/common/CMakeLists.txt +++ b/dune/common/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory("parallel") add_subdirectory("std") -add_subdirectory("test" EXCLUDE_FROM_ALL) +add_subdirectory("test") #build the library dunecommon if(LAPACK_FOUND) diff --git a/dune/common/parallel/CMakeLists.txt b/dune/common/parallel/CMakeLists.txt index 034f4e8ca..cb1be5772 100644 --- a/dune/common/parallel/CMakeLists.txt +++ b/dune/common/parallel/CMakeLists.txt @@ -1,4 +1,4 @@ -add_subdirectory("test" EXCLUDE_FROM_ALL) +add_subdirectory(test) #install headers install(FILES diff --git a/dune/common/parallel/test/CMakeLists.txt b/dune/common/parallel/test/CMakeLists.txt index 0daa7bbef..ca20f7387 100644 --- a/dune/common/parallel/test/CMakeLists.txt +++ b/dune/common/parallel/test/CMakeLists.txt @@ -1,10 +1,5 @@ set(MPITESTPROGS indicestest indexsettest syncertest selectiontest variablesizecommunicatortest) -add_directory_test_target(_test_target) -# We do not want want to build the tests during make all, -# but just build them on demand -add_dependencies(${_test_target} ${MPITESTPROGS}) - add_executable("indexsettest" indexsettest.cc) target_link_libraries("indexsettest" "dunecommon" ${CMAKE_THREAD_LIBS_INIT} ${}) diff --git a/dune/common/test/CMakeLists.txt b/dune/common/test/CMakeLists.txt index 2d791a9e6..f076c0302 100644 --- a/dune/common/test/CMakeLists.txt +++ b/dune/common/test/CMakeLists.txt @@ -1,209 +1,154 @@ -# tests that should build and run successfully -set(TESTS - arraylisttest - arraytest - bigunsignedinttest - bitsetvectortest - calloncetest - check_fvector_size - classnametest - conversiontest - diagonalmatrixtest - dynmatrixtest - dynvectortest - enumsettest - fmatrixtest - fvectortest - gcdlcmtest - integersequence - iteratorfacadetest - iteratorfacadetest2 - lrutest - mpicollectivecommunication - mpiguardtest - mpihelpertest - mpihelpertest2 - nullptr_test - pathtest - parametertreelocaletest - parametertreetest - poolallocatortest - shared_ptrtest_config - singletontest - streamtest - stringutilitytest - testfloatcmp - tuplestest - tupleutilitytest - typetraitstest - typetraitstest_deprecated - utilitytest) - -#test that should build but fail to run successfully -set(FAILTESTS - testdebugallocator_fail1 - testdebugallocator_fail2 - testdebugallocator_fail3 - testdebugallocator_fail4 - testdebugallocator_fail5 - ) - -set(COMPILEFAILTESTS - check_fvector_size_fail1 - check_fvector_size_fail2 - genericiterator_compile_fail - nullptr-test-fail) - -# Add the executables needed for the tests -add_executable("arraylisttest" arraylisttest.cc) -add_executable("arraytest" arraytest.cc) - -add_executable("bigunsignedinttest" bigunsignedinttest.cc) -target_link_libraries("bigunsignedinttest" "dunecommon") - -add_executable("bitsetvectortest" bitsetvectortest.cc) -add_executable("calloncetest" calloncetest.cc) -target_link_libraries("calloncetest" "dunecommon") -add_executable("check_fvector_size" check_fvector_size.cc) -add_executable("check_fvector_size_fail1" EXCLUDE_FROM_ALL check_fvector_size_fail.cc) -set_target_properties(check_fvector_size_fail1 PROPERTIES COMPILE_FLAGS "-DDIM=1") -add_executable("check_fvector_size_fail2" EXCLUDE_FROM_ALL check_fvector_size_fail.cc) -set_target_properties(check_fvector_size_fail2 PROPERTIES COMPILE_FLAGS "-DDIM=3") -add_executable("classnametest" classnametest.cc) -add_executable("conversiontest" conversiontest.cc) - -add_executable("dynmatrixtest" dynmatrixtest.cc) -target_link_libraries("dynmatrixtest" "dunecommon") - -add_executable("dynvectortest" dynvectortest.cc) +dune_add_test(SOURCES arraylisttest.cc) -if(${LAPACK_FOUND}) - add_executable(eigenvaluestest eigenvaluestest.cc) - target_link_libraries(eigenvaluestest dunecommon) - target_link_libraries(eigenvaluestest ${LAPACK_LIBRARIES}) - list(APPEND TESTS eigenvaluestest) -endif() +dune_add_test(SOURCES arraytest.cc) + +dune_add_test(SOURCES bigunsignedinttest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES bitsetvectortest.cc) + +dune_add_test(SOURCES calloncetest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES check_fvector_size.cc) + +dune_add_test(NAME check_fvector_size_fail1 + SOURCES check_fvector_size_fail.cc + COMPILE_DEFINITIONS DIM=1 + EXPECT_COMPILE_FAIL) + +dune_add_test(NAME check_fvector_size_fail2 + SOURCES check_fvector_size_fail.cc + COMPILE_DEFINITIONS DIM=3 + EXPECT_COMPILE_FAIL) + +dune_add_test(SOURCES classnametest.cc) + +dune_add_test(SOURCES conversiontest.cc) + +dune_add_test(SOURCES diagonalmatrixtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES dynmatrixtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES dynvectortest.cc) + +dune_add_test(SOURCES enumsettest.cc) + +dune_add_test(NAME fmatrixtest + SOURCES fmatrixtest.cc dummy.f + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES fvectortest.cc) + +dune_add_test(SOURCES genericiterator_compile_fail.cc + EXPECT_COMPILE_FAIL) + +dune_add_test(SOURCES gcdlcmtest.cc) + +dune_add_test(SOURCES integersequence.cc) + +dune_add_test(SOURCES iteratorfacadetest2.cc) + +dune_add_test(SOURCES iteratorfacadetest.cc) + +dune_add_test(SOURCES lrutest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES mpicollectivecommunication.cc + LINK_LIBRARIES dunecommon + SKIP_ON_77) + +dune_add_test(SOURCES mpiguardtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES mpihelpertest.cc) + +dune_add_test(NAME mpihelpertest2 + SOURCES mpihelpertest.cc + COMPILE_DEFINITIONS MPIHELPER_PREINITIALIZE) + +dune_add_test(NAME nullptr-test + SOURCES nullptr-test.cc nullptr-test2.cc) + +dune_add_test(NAME nullptr_test_fail + SOURCES nullptr-test.cc + COMPILE_DEFINITIONS FAIL + LINK_LIBRARIES dunecommon + EXPECT_COMPILE_FAIL) + +dune_add_test(SOURCES parametertreelocaletest.cc + LINK_LIBRARIES dunecommon + SKIP_ON_77) + +dune_add_test(SOURCES parametertreetest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES pathtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES poolallocatortest.cc) + +dune_add_test(SOURCES shared_ptrtest.cc) + +dune_add_test(SOURCES singletontest.cc) + +dune_add_test(SOURCES sllisttest.cc) + +dune_add_test(SOURCES streamtest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES stringutilitytest.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon) + +dune_add_test(NAME testdebugallocator_fail1 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE1;EXPECTED_SIGNAL=SIGSEGV" + EXPECT_FAIL) + +dune_add_test(NAME testdebugallocator_fail2 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE2;EXPECTED_SIGNAL=SIGABRT" + EXPECT_FAIL) + +dune_add_test(NAME testdebugallocator_fail3 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE3;EXPECTED_SIGNAL=SIGABRT" + EXPECT_FAIL) + +dune_add_test(NAME testdebugallocator_fail4 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE4;DEBUG_ALLOCATOR_KEEP=1;EXPECTED_SIGNAL=SIGSEGV" + EXPECT_FAIL) + +dune_add_test(NAME testdebugallocator_fail5 + SOURCES testdebugallocator.cc + LINK_LIBRARIES dunecommon + COMPILE_DEFINITIONS "FAILURE5;EXPECTED_SIGNAL=SIGSEGV" + EXPECT_FAIL) + +dune_add_test(SOURCES testfloatcmp.cc) + +dune_add_test(SOURCES tuplestest.cc) + +dune_add_test(SOURCES tupleutilitytest.cc) + +dune_add_test(SOURCES typetraitstest.cc) + +dune_add_test(SOURCES typetraitstest_deprecated.cc) + +#dune_add_test(SOURCES utilitytest.cc) -add_executable("diagonalmatrixtest" diagonalmatrixtest.cc) -target_link_libraries("diagonalmatrixtest" "dunecommon") - -add_executable("enumsettest" enumsettest.cc) - -add_executable("testfloatcmp" testfloatcmp.cc) -target_link_libraries("testfloatcmp" "dunecommon") - -# we provide an empty fortran file to force the linker -# to link to the fortran libraries (needed for static linking) -add_executable("fmatrixtest" fmatrixtest.cc dummy.f) -target_link_libraries("fmatrixtest" "dunecommon") -add_executable("fvectortest" fvectortest.cc) -add_dune_gmp_flags("fvectortest") -add_executable("gcdlcmtest" gcdlcmtest.cc) -add_executable("genericiterator_compile_fail" EXCLUDE_FROM_ALL genericiterator_compile_fail.cc) -add_executable("integersequence" integersequence.cc) -add_executable("iteratorfacadetest2" iteratorfacadetest2.cc) -add_executable("iteratorfacadetest" iteratorfacadetest.cc) -add_executable("lrutest" lrutest.cc) -target_link_libraries("lrutest" "dunecommon") -add_executable("mpiguardtest" mpiguardtest.cc) -target_link_libraries("mpiguardtest" "dunecommon") -add_DUNE_MPI_flags(mpiguardtest) - -add_executable("mpicollectivecommunication" mpicollectivecommunication.cc) -target_link_libraries(mpicollectivecommunication "dunecommon") -add_DUNE_MPI_flags(mpicollectivecommunication) - -add_executable("mpihelpertest" mpihelpertest.cc) -target_link_libraries(mpihelpertest "dunecommon") -add_DUNE_MPI_flags(mpihelpertest) - -add_executable("mpihelpertest2" mpihelpertest.cc) -target_link_libraries(mpihelpertest2 "dunecommon") -add_DUNE_MPI_flags(mpihelpertest2) -set_target_properties(mpihelpertest2 PROPERTIES COMPILE_FLAGS "-DMPIHELPER_PREINITIALIZE") - -add_executable("nullptr_test" nullptr-test.cc nullptr-test2.cc) -target_link_libraries(nullptr_test "dunecommon") -add_executable("nullptr_test_fail" EXCLUDE_FROM_ALL nullptr-test.cc) -target_link_libraries(nullptr_test_fail "dunecommon") -set_target_properties(nullptr_test_fail PROPERTIES COMPILE_FLAGS "-DFAIL") - -add_executable("parametertreelocaletest" parametertreelocaletest.cc) -target_link_libraries("parametertreelocaletest" "dunecommon") - -add_executable("parametertreetest" parametertreetest.cc) -target_link_libraries("parametertreetest" "dunecommon") - -add_executable("pathtest" pathtest.cc) -target_link_libraries("pathtest" "dunecommon") - -add_executable("poolallocatortest" poolallocatortest.cc) -add_executable("shared_ptrtest_config" shared_ptrtest.cc) -add_executable("singletontest" singletontest.cc) -add_executable("sllisttest" EXCLUDE_FROM_ALL sllisttest.cc) - -add_executable("streamtest" streamtest.cc) -target_link_libraries("streamtest" "dunecommon") - -add_executable("stringutilitytest" stringutilitytest.cc) -target_link_libraries("stringutilitytest" "dunecommon") - -add_executable("testdebugallocator" testdebugallocator.cc) -target_link_libraries(testdebugallocator dunecommon) -add_executable("testdebugallocator_fail1" testdebugallocator.cc) -target_link_libraries(testdebugallocator_fail1 dunecommon) -set_target_properties(testdebugallocator_fail1 PROPERTIES COMPILE_DEFINITIONS "FAILURE1;EXPECTED_SIGNAL=SIGSEGV") -add_executable("testdebugallocator_fail2" testdebugallocator.cc) -target_link_libraries(testdebugallocator_fail2 dunecommon) -set_target_properties(testdebugallocator_fail2 PROPERTIES COMPILE_DEFINITIONS "FAILURE2;EXPECTED_SIGNAL=SIGABRT") -add_executable("testdebugallocator_fail3" testdebugallocator.cc) -target_link_libraries(testdebugallocator_fail3 dunecommon) -set_target_properties(testdebugallocator_fail3 PROPERTIES COMPILE_DEFINITIONS "FAILURE3;EXPECTED_SIGNAL=SIGABRT") -add_executable("testdebugallocator_fail4" testdebugallocator.cc) -target_link_libraries(testdebugallocator_fail4 dunecommon) -set_target_properties(testdebugallocator_fail4 PROPERTIES COMPILE_DEFINITIONS "FAILURE4;DEBUG_ALLOCATOR_KEEP=1;EXPECTED_SIGNAL=SIGSEGV") -add_executable("testdebugallocator_fail5" testdebugallocator.cc) -target_link_libraries(testdebugallocator_fail5 dunecommon) -set_target_properties(testdebugallocator_fail5 PROPERTIES COMPILE_DEFINITIONS "FAILURE5;EXPECTED_SIGNAL=SIGSEGV") - -add_executable("tuplestest" tuplestest.cc) -add_executable("tupleutilitytest" tupleutilitytest.cc) -add_executable("typetraitstest" typetraitstest.cc) -add_executable("typetraitstest_deprecated" typetraitstest_deprecated.cc) -add_executable("utilitytest" utilitytest.cc) - -set(TESTPROGS ${TESTS} ${FAILTESTS}) - -# We do not want want to build the tests during make all, -# but just build them on demand -add_directory_test_target(_test_target) -add_dependencies(${_test_target} ${TESTPROGS}) - -# Add the tests to be executed -foreach(_TEST ${TESTPROGS}) - add_test(${_TEST} ${_TEST}) -endforeach(_TEST) - -# treat tests returning code 77 as skipped -set_tests_properties( - mpicollectivecommunication - parametertreelocaletest - PROPERTIES SKIP_RETURN_CODE 77) if(${LAPACK_FOUND}) - set_tests_properties(eigenvaluestest - PROPERTIES SKIP_RETURN_CODE 77) + dune_add_test(SOURCES eigenvaluestest.cc + LINK_LIBRARIES dunecommon + SKIP_ON_77) endif() - -# set properties for failing tests -set_tests_properties( - ${FAILTESTS} - PROPERTIES WILL_FAIL true) - -# compile tests that should fail -foreach(_TEST ${COMPILEFAILTESTS}) - add_test(NAME ${_TEST} - COMMAND ${CMAKE_COMMAND} --build . --target ${_TEST} --config $<CONFIGURATION>) -endforeach(_TEST) -set_tests_properties( - ${COMPILEFAILTESTS} - PROPERTIES WILL_FAIL true) -- GitLab