]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Some improvement
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 19 Aug 2013 21:17:52 +0000 (21:17 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 19 Aug 2013 21:17:52 +0000 (21:17 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@30344 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/CMakeLists.txt
deal.II/cmake/macros/macro_deal_ii_add_test.cmake
deal.II/cmake/scripts/run_test.cmake [new file with mode: 0644]
tests/CMakeLists.txt
tests/base/CMakeLists.txt
tests/base/anisotropic_1.cc

index c7f0ab92d4833cc46c6ef9b5e8231fa6ef2bc3b6..47240b388def51c62c8641e276d23b078ae7efd2 100644 (file)
@@ -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()
 
 #
index 9ebd61efc11cbd482e2c56870764953bb3b97a6c..a8a106211e3a7280cfc78a95ce5d3e99d6fb55bb 100644 (file)
@@ -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 (file)
index 0000000..d05190d
--- /dev/null
@@ -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"
+  )
+
index 56cf69c9b5859dadec918369585494f0aa9c4656..7dea0b5c3359c4daeeaf73883d200680b4e23df0 100644 (file)
@@ -1,4 +1,6 @@
 MESSAGE(STATUS "Registering tests")
+
 ADD_SUBDIRECTORY(base)
+
 #ADD_SUBDIRECTORY(bits)
 #ADD_SUBDIRECTORY(fe)
index 34c42d8870cd4d62778dd9d464aedb13cfd68cbc..dadada8b783136ffd37bcff950f4886ad6d74b80 100644 (file)
@@ -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)
index 30746cd61ea90667ae03a04dc41edc4ff76b7789..85dfa92aa3388dee2fbfd764b18967f413d113c8 100644 (file)
@@ -146,7 +146,7 @@ check_dimensions (const std::vector<Polynomial<double> > &p)
 
 int main()
 {
-  std::ofstream logfile("anisotropic_1/output");
+  std::ofstream logfile("output");
   deallog << std::setprecision(2);
   deallog.attach(logfile);
   deallog.depth_console(0);

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.