summaryrefslogtreecommitdiffstats
path: root/Source/cmCreateTestSourceList.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2002-12-11 16:32:43 (GMT)
committerBrad King <brad.king@kitware.com>2002-12-11 16:32:43 (GMT)
commite9e3855c65e9ee32119645d6e4044ba0ee8b8a06 (patch)
tree56b6848eb0227bee3002e532788785140f6174f0 /Source/cmCreateTestSourceList.cxx
parent1c6203b4060ab8b14534085c3e4ccf635d2ff43d (diff)
downloadCMake-e9e3855c65e9ee32119645d6e4044ba0ee8b8a06.zip
CMake-e9e3855c65e9ee32119645d6e4044ba0ee8b8a06.tar.gz
CMake-e9e3855c65e9ee32119645d6e4044ba0ee8b8a06.tar.bz2
ENH: Generate code to setup MSVC debug library hook. The test driver program will not display error dialogs if DART_TEST_FROM_DART is set in the environment.
Diffstat (limited to 'Source/cmCreateTestSourceList.cxx')
-rw-r--r--Source/cmCreateTestSourceList.cxx38
1 files changed, 29 insertions, 9 deletions
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index e1411fa..62286bc 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -97,6 +97,21 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
"#include <stdio.h>\n"
"#include <string.h>\n"
"#include <stdlib.h>\n";
+ fout <<
+ "#if defined(_MSC_VER) && defined(_DEBUG)\n"
+ "/* MSVC debug hook to prevent dialogs when running from DART. */\n"
+ "# include <crtdbg.h>\n"
+ "static int TestDriverDebugReport(int type, char* message, int* retVal)\n"
+ "{\n"
+ " (void)type; (void)retVal;\n"
+ " if(getenv(\"DART_TEST_FROM_DART\"))\n"
+ " {\n"
+ " fprintf(stderr, message);\n"
+ " exit(1);\n"
+ " }\n"
+ " return 0;\n"
+ "}\n"
+ "#endif\n";
if(extraInclude.size())
{
fout << "#include \"" << extraInclude << "\"\n";
@@ -104,7 +119,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
fout <<
"\n"
- "// Forward declare test functions\n"
+ "/* Forward declare test functions. */\n"
"\n";
std::vector<std::string>::iterator testsBegin = i;
@@ -143,7 +158,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
fout <<
"\n"
- "// Create map\n"
+ "/* Create map. */\n"
"\n"
"typedef int (*MainFuncPointer)(int , char*[]);\n"
"typedef struct\n"
@@ -179,8 +194,8 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
fout <<
"};\n"
"\n"
- "// Allocate and create a lowercased copy of string\n"
- "// (note that it has to be free'd manually)\n"
+ "/* Allocate and create a lowercased copy of string\n"
+ " (note that it has to be free'd manually) */\n"
"\n"
"char* lowercase(const char *string)\n"
"{\n"
@@ -205,19 +220,24 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
" int i, NumTests, testNum, partial_match;\n"
" char *arg, *test_name;\n"
" \n"
+ "#if defined(_MSC_VER) && defined(_DEBUG)\n"
+ " /* Put in hook for debug library. */\n"
+ " _CrtSetReportHook(TestDriverDebugReport);\n"
+ "#endif\n"
+ " \n"
" NumTests = " << numTests << ";\n"
" \n"
- " // If no test name was given\n";
+ " /* If no test name was given */\n";
if(function.size())
{
- fout << " // process command line with user function\n"
+ fout << " /* process command line with user function. */\n"
<< " " << function << "(&ac, &av);\n";
}
fout <<
" if (ac < 2)\n"
" {\n"
- " // Ask for a test\n"
+ " /* Ask for a test. */\n"
" printf(\"Available tests:\\n\");\n"
" for (i =0; i < NumTests; ++i)\n"
" {\n"
@@ -234,7 +254,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
" return (*cmakeGeneratedFunctionMapEntries[testNum].func)(ac-1, av+1);\n"
" }\n"
" \n"
- " // If partial match is requested\n"
+ " /* If partial match is requested. */\n"
" partial_match = (strcmp(av[1], \"-R\") == 0) ? 1 : 0;\n"
" if (partial_match && ac < 3)\n"
" {\n"
@@ -262,7 +282,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
" }\n"
" free(arg);\n"
" \n"
- " // Nothing was run, display the test names\n"
+ " /* Nothing was run, display the test names. */\n"
" printf(\"Available tests:\\n\");\n"
" for (i =0; i < NumTests; ++i)\n"
" {\n"