diff --git a/Common/Log.cpp b/Common/Log.cpp index 422ca88f0a..1a1df0be45 100644 --- a/Common/Log.cpp +++ b/Common/Log.cpp @@ -32,6 +32,8 @@ #define LOG_BUF_SIZE 2048 +static bool hitAnyAsserts = false; + bool HandleAssert(const char *function, const char *file, int line, const char *expression, const char* format, ...) { // Read message and write it to the log char text[LOG_BUF_SIZE]; @@ -50,16 +52,22 @@ bool HandleAssert(const char *function, const char *file, int line, const char * // Also do a simple printf for good measure, in case logging of SYSTEM is disabled (should we disallow that?) fprintf(stderr, "%s\n", formatted); + hitAnyAsserts = true; + #if defined(USING_WIN_UI) - int msgBoxStyle = MB_ICONINFORMATION | MB_YESNO; - std::wstring wtext = ConvertUTF8ToWString(formatted) + L"\n\nTry to continue?"; - std::wstring wcaption = ConvertUTF8ToWString(caption); - OutputDebugString(wtext.c_str()); - if (IDYES != MessageBox(0, wtext.c_str(), wcaption.c_str(), msgBoxStyle)) { - return false; - } else { - return true; + // Avoid hanging on CI. + if (!getenv("CI")) { + int msgBoxStyle = MB_ICONINFORMATION | MB_YESNO; + std::wstring wtext = ConvertUTF8ToWString(formatted) + L"\n\nTry to continue?"; + std::wstring wcaption = ConvertUTF8ToWString(caption); + OutputDebugString(wtext.c_str()); + if (IDYES != MessageBox(0, wtext.c_str(), wcaption.c_str(), msgBoxStyle)) { + return false; + } else { + return true; + } } + return false; #elif PPSSPP_PLATFORM(ANDROID) __android_log_assert(expression, "PPSSPP", "%s", formatted); // Doesn't matter what we return here. @@ -69,3 +77,11 @@ bool HandleAssert(const char *function, const char *file, int line, const char * return false; #endif } + +// These are mainly used for unit testing. +bool HitAnyAsserts() { + return hitAnyAsserts; +} +void ResetHitAnyAsserts() { + hitAnyAsserts = false; +} diff --git a/Common/Log.h b/Common/Log.h index f8a56730a6..9821642f9f 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -116,6 +116,9 @@ __attribute__((format(printf, 5, 6))) #endif ; +bool HitAnyAsserts(); +void ResetHitAnyAsserts(); + #if defined(__ANDROID__) // Tricky macro to get the basename, that also works if *built* on Win32. // Doesn't mean this macro can be used on Win32 though.