Skip to content

Commit cd1b8be

Browse files
nga888mstorsjo
authored andcommitted
[libcxx] [test] Make set_windows_crt_report_mode.h more explicit
This header is included when building with a debug CRT in MSVC/Clang-cl environments. By default, failed asserts with the debug CRT pops up a blocking dialog box alerting the user about the failed assert. When running more than one test in an automated fashion, this isn't ideal. This header tries to run initializers to set the behaviour of the failed asserts to print a message to the console, just like the default is in release mode. This is previously done by setting the reporting mode to _CRTDBG_MODE_DEBUG, which means outputting to the debugger's output window. In some setups, this is enough for making it work, but in others it instead can pop up a dialog asking for which debugger to use. Instead set the mode explicitly to _CRTDBG_MODE_FILE and set the destination to be explicitly to stderr. For setups where the previous code worked correctly, it doesn't make any difference other than that a failed assert prints an additional "abort() has been called" message that wasn't printed before. Differential Revision: https://reviews.llvm.org/D155823
1 parent e346fd8 commit cd1b8be

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

libcxx/test/support/set_windows_crt_report_mode.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@
3333
// that setting and instead changes the assertion handler to log to stderr
3434
// instead.
3535
inline int init_crt_report_mode() {
36-
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
37-
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
38-
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
36+
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
37+
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
38+
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
39+
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
40+
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
41+
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
3942
return 0;
4043
}
4144

0 commit comments

Comments
 (0)