ENH: Improved implementation of MSVC debug hook to only add the hook if DART_TEST_FROM_DART is set in the environment. This is better than always adding the hook and testing the environment from the callback.
This commit is contained in:
parent
682e2c7b8b
commit
3bcbca96ab
|
@ -96,7 +96,8 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
||||||
"#include <ctype.h>\n"
|
"#include <ctype.h>\n"
|
||||||
"#include <stdio.h>\n"
|
"#include <stdio.h>\n"
|
||||||
"#include <string.h>\n"
|
"#include <string.h>\n"
|
||||||
"#include <stdlib.h>\n";
|
"#include <stdlib.h>\n"
|
||||||
|
"\n";
|
||||||
fout <<
|
fout <<
|
||||||
"#if defined(_MSC_VER) && defined(_DEBUG)\n"
|
"#if defined(_MSC_VER) && defined(_DEBUG)\n"
|
||||||
"/* MSVC debug hook to prevent dialogs when running from DART. */\n"
|
"/* MSVC debug hook to prevent dialogs when running from DART. */\n"
|
||||||
|
@ -104,11 +105,8 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
||||||
"static int TestDriverDebugReport(int type, char* message, int* retVal)\n"
|
"static int TestDriverDebugReport(int type, char* message, int* retVal)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" (void)type; (void)retVal;\n"
|
" (void)type; (void)retVal;\n"
|
||||||
" if(getenv(\"DART_TEST_FROM_DART\"))\n"
|
" fprintf(stderr, message);\n"
|
||||||
" {\n"
|
" exit(1);\n"
|
||||||
" fprintf(stderr, message);\n"
|
|
||||||
" exit(1);\n"
|
|
||||||
" }\n"
|
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"#endif\n";
|
"#endif\n";
|
||||||
|
@ -221,8 +219,11 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
||||||
" char *arg, *test_name;\n"
|
" char *arg, *test_name;\n"
|
||||||
" \n"
|
" \n"
|
||||||
"#if defined(_MSC_VER) && defined(_DEBUG)\n"
|
"#if defined(_MSC_VER) && defined(_DEBUG)\n"
|
||||||
" /* Put in hook for debug library. */\n"
|
" /* If running from DART, put in debug hook. */\n"
|
||||||
" _CrtSetReportHook(TestDriverDebugReport);\n"
|
" if(getenv(\"DART_TEST_FROM_DART\"))\n"
|
||||||
|
" {\n"
|
||||||
|
" _CrtSetReportHook(TestDriverDebugReport);\n"
|
||||||
|
" }\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
" \n"
|
" \n"
|
||||||
" NumTests = " << numTests << ";\n"
|
" NumTests = " << numTests << ";\n"
|
||||||
|
|
|
@ -2434,16 +2434,16 @@ void cmSystemTools::SplitProgramFromArgs(const char* path,
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
static int cmSystemToolsDebugReport(int, char* message, int*)
|
static int cmSystemToolsDebugReport(int, char* message, int*)
|
||||||
{
|
{
|
||||||
if(getenv("DART_TEST_FROM_DART"))
|
fprintf(stderr, message);
|
||||||
{
|
exit(1);
|
||||||
fprintf(stderr, message);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void cmSystemTools::EnableMSVCDebugHook()
|
void cmSystemTools::EnableMSVCDebugHook()
|
||||||
{
|
{
|
||||||
_CrtSetReportHook(cmSystemToolsDebugReport);
|
if(getenv("DART_TEST_FROM_DART"))
|
||||||
|
{
|
||||||
|
_CrtSetReportHook(cmSystemToolsDebugReport);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void cmSystemTools::EnableMSVCDebugHook()
|
void cmSystemTools::EnableMSVCDebugHook()
|
||||||
|
|
Loading…
Reference in New Issue