Page MenuHomePhabricator

Disable Operating System Debug/Error Popups while running faulty tests on Windows
Closed, ResolvedPublic

Description

If the Visual C runtime encounters an failed assertion, it popups an error box allowing to debug or abort the process. This leads to problems while running automated units tests.

Following code needs to be run/added to test initialization routines (maybe there where the mitk logging backend is enabled in tests):

void DisableWindowsAndVisualCErrorReporting( )
{
#ifdef WIN32

SetErrorMode( SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX );
#ifdef _DEBUG
  _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
  _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
#endif

#endif
}

This code works for a while now in MES, which it needs for its sub-process management.

Event Timeline

Following includes are required to compile the statements in the previous comment:

#ifdef WIN32

#include <windows.h>
#if defined _DEBUG
  #include <crtdbg.h>
#endif

#endif

kislinsk claimed this task.