소스 검색

ENH: CTest driver now catches std::exception and print a message.

Jean-Christophe Fillion-Robin 15 년 전
부모
커밋
ecfe7801b9
1개의 변경된 파일18개의 추가작업 그리고 0개의 파일을 삭제
  1. 18 0
      CMakeLists.txt

+ 18 - 0
CMakeLists.txt

@@ -65,6 +65,24 @@ IF(BUILD_TESTING)
     ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
     @ONLY
     )
+
+  # Configuration for the CMake-generated test driver
+  SET(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include <stdexcept>")
+  SET(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
+    try
+      {")
+  SET(CMAKE_TESTDRIVER_AFTER_TESTMAIN "    }
+      catch( std::exception & excp )
+        {
+        fprintf(stderr,\"%s\\n\",excp.what());
+        return EXIT_FAILURE;
+        }
+      catch( ... )
+        {
+        printf(\"Exception caught in the test driver\\n\");
+        return EXIT_FAILURE;
+        }
+      ")
 ENDIF()
 
 #-----------------------------------------------------------------------------