From: Matthias Maier Date: Mon, 19 Aug 2013 21:17:52 +0000 (+0000) Subject: Some improvement X-Git-Tag: v8.1.0~570^2~463 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9577474d87a568b925c87b91868b22ee252801b3;p=dealii.git Some improvement git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@30344 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index c7f0ab92d4..47240b388d 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -146,7 +146,8 @@ ADD_SUBDIRECTORY(contrib) # has to be included after source ADD_SUBDIRECTORY(examples) IF(DEAL_II_HAVE_TESTS_DIRECTORY) - ADD_SUBDIRECTORY(${TEST_DIR} ${CMAKE_BINARY_DIR}/tests_ext) + ENABLE_TESTING() + ADD_SUBDIRECTORY(${TEST_DIR} ${CMAKE_BINARY_DIR}/tests) ENDIF() # diff --git a/deal.II/cmake/macros/macro_deal_ii_add_test.cmake b/deal.II/cmake/macros/macro_deal_ii_add_test.cmake index 9ebd61efc1..a8a106211e 100644 --- a/deal.II/cmake/macros/macro_deal_ii_add_test.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_add_test.cmake @@ -19,7 +19,7 @@ # DEAL_II_ADD_TEST(category test_name [configurations]) # -MACRO(DEAL_II_ADD_TEST _category _test_target) +MACRO(DEAL_II_ADD_TEST _category _test_name) FOREACH(_build ${DEAL_II_BUILD_TYPES}) @@ -27,27 +27,45 @@ MACRO(DEAL_II_ADD_TEST _category _test_target) IF(_match OR "${ARGN}" STREQUAL "") STRING(TOLOWER ${_build} _build_lowercase) - ADD_EXECUTABLE(${_test_target}.${_build_lowercase} - EXCLUDE_FROM_ALL - ${_test_target}.cc - ) - SET_TARGET_PROPERTIES(${_test_target}.${_build_lowercase} PROPERTIES + SET(_test ${_test_name}.${_build_lowercase}) + + ADD_EXECUTABLE(${_test} EXCLUDE_FROM_ALL ${_test_name}.cc) + + SET_TARGET_PROPERTIES(${_test} PROPERTIES LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}" COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${_build}}" LINKER_LANGUAGE "CXX" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_test}" ) - SET_PROPERTY(TARGET ${_test_target}.${_build_lowercase} APPEND PROPERTY + SET_PROPERTY(TARGET ${_test} APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/include" "${CMAKE_SOURCE_DIR}/include" ) - TARGET_LINK_LIBRARIES(${_test_target}.${_build_lowercase} + SET_PROPERTY(TARGET ${_test} APPEND PROPERTY + COMPILE_DEFINITIONS + SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} + ) + TARGET_LINK_LIBRARIES(${_test_name}.${_build_lowercase} ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX} ) - ADD_TEST(${_test_target}.${_build_lowercase}.build - ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${_test_target}.${_build_lowercase} + ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_test}/output + COMMAND ${_test} + DEPENDS ${_test} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_test} + ) + ADD_CUSTOM_TARGET(${_test}.run + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_test}/output + ) + + ADD_TEST(NAME ${_test} + COMMAND ${CMAKE_COMMAND} + -DTEST=${_test} + -DDEAL_II_BINARY_DIR=${CMAKE_BINARY_DIR} + -P ${CMAKE_SOURCE_DIR}/cmake/scripts/run_test.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_test} ) ENDIF() diff --git a/deal.II/cmake/scripts/run_test.cmake b/deal.II/cmake/scripts/run_test.cmake new file mode 100644 index 0000000000..d05190d19d --- /dev/null +++ b/deal.II/cmake/scripts/run_test.cmake @@ -0,0 +1,38 @@ +# +# The following variables have to be set: +# +# TEST +# DEAL_II_BINARY_DIR +# + +MACRO(CALLBACK _target _msg_success _msg_error) + EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} + --build ${DEAL_II_BINARY_DIR} --target ${_target} + RESULT_VARIABLE _result_code + OUTPUT_VARIABLE _output + ) + + IF("${_result_code}" STREQUAL "0") + MESSAGE("${_target}: ${_msg_success}.") + + ELSE() + + MESSAGE("${_target}: ${_msg_error}:") + MESSAGE(${_output}) + MESSAGE(FATAL_ERROR "${TEST}: Test aborted.") + ENDIF() +ENDMACRO() + + +CALLBACK(${TEST} + "Build successful" "Build failed with the following error message" + ) + +CALLBACK(${TEST}.run + "Run successful" "Running the test failed with the following error message" + ) + +CALLBACK(${TEST}.compare + "Run successful" "Running the test failed with the following error message" + ) + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 56cf69c9b5..7dea0b5c33 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,6 @@ MESSAGE(STATUS "Registering tests") + ADD_SUBDIRECTORY(base) + #ADD_SUBDIRECTORY(bits) #ADD_SUBDIRECTORY(fe) diff --git a/tests/base/CMakeLists.txt b/tests/base/CMakeLists.txt index 34c42d8870..dadada8b78 100644 --- a/tests/base/CMakeLists.txt +++ b/tests/base/CMakeLists.txt @@ -1,6 +1,6 @@ GET_FILENAME_COMPONENT(_category ${CMAKE_CURRENT_SOURCE_DIR} NAME) -FILE(GLOB _tests "*.cc") +FILE(GLOB _tests "anisotropic_1.cc") FOREACH(_test ${_tests}) GET_FILENAME_COMPONENT(_test ${_test} NAME_WE) diff --git a/tests/base/anisotropic_1.cc b/tests/base/anisotropic_1.cc index 30746cd61e..85dfa92aa3 100644 --- a/tests/base/anisotropic_1.cc +++ b/tests/base/anisotropic_1.cc @@ -146,7 +146,7 @@ check_dimensions (const std::vector > &p) int main() { - std::ofstream logfile("anisotropic_1/output"); + std::ofstream logfile("output"); deallog << std::setprecision(2); deallog.attach(logfile); deallog.depth_console(0);