Suppress assert dialog boxes when running CI tests
This commit is contained in:
parent
cd9d0c1b0f
commit
bdbf9e5d6a
1 changed files with 25 additions and 1 deletions
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char* kRunAsNode = "ELECTRON_RUN_AS_NODE";
|
const auto kRunAsNode = "ELECTRON_RUN_AS_NODE";
|
||||||
|
|
||||||
bool IsEnvSet(const char* name) {
|
bool IsEnvSet(const char* name) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
@ -56,6 +56,30 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||||
|
|
||||||
bool run_as_node = IsEnvSet(kRunAsNode);
|
bool run_as_node = IsEnvSet(kRunAsNode);
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
// Don't display assert dialog boxes in CI test runs
|
||||||
|
static const auto kCI = "ELECTRON_CI";
|
||||||
|
bool is_ci = IsEnvSet(kCI);
|
||||||
|
if (!is_ci) {
|
||||||
|
for (int i = 0; i < argc; ++i) {
|
||||||
|
if (!_wcsicmp(wargv[i], L"--ci")) {
|
||||||
|
is_ci = true;
|
||||||
|
_putenv_s(kCI, "1"); // set flag for child processes
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_ci) {
|
||||||
|
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
|
||||||
|
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
|
||||||
|
|
||||||
|
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
|
||||||
|
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
|
||||||
|
|
||||||
|
_set_error_mode(_OUT_TO_STDERR);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Make sure the output is printed to console.
|
// Make sure the output is printed to console.
|
||||||
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
|
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
|
||||||
base::RouteStdioToConsole(false);
|
base::RouteStdioToConsole(false);
|
||||||
|
|
Loading…
Reference in a new issue