From: Vladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com> Date: Mon, 8 Apr 2019 17:01:41 +0000 (+0700) Subject: Enable MSVC assert report box [Abort|Retry|Ignore] if a debugger is present (#5279) X-Git-Tag: v1.11.0~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd85c3b721c97dc12b67235080e23edeba8d14e8;p=platform%2Fupstream%2Fflatbuffers.git Enable MSVC assert report box [Abort|Retry|Ignore] if a debugger is present (#5279) --- diff --git a/tests/test_assert.cpp b/tests/test_assert.cpp index 804663c..ccbce23 100644 --- a/tests/test_assert.cpp +++ b/tests/test_assert.cpp @@ -4,6 +4,7 @@ #ifdef _MSC_VER # include +# include #endif int testing_fails = 0; @@ -43,15 +44,19 @@ void InitTestEngine(TestFailEventListener listener) { // clang-format off #ifdef _MSC_VER - // Send all reports to STDOUT. + // By default, send all reports to STDOUT to prevent CI hangs. + // Enable assert report box [Abort|Retry|Ignore] if a debugger is present. + const int dbg_mode = (_CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG) | + (IsDebuggerPresent() ? _CRTDBG_MODE_WNDW : 0); + (void)dbg_mode; // release mode fix // CrtDebug reports to _CRT_WARN channel. - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportMode(_CRT_WARN, dbg_mode); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); // The assert from reports to _CRT_ERROR channel - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportMode(_CRT_ERROR, dbg_mode); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT); // Internal CRT assert channel? - _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportMode(_CRT_ASSERT, dbg_mode); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); #endif