2022-10-13 11:24:15 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "LowLevelTestsRunner/CheckScope.h"
|
|
|
|
|
#include "Containers/StringConv.h"
|
|
|
|
|
#include "CoreGlobals.h"
|
|
|
|
|
#include "Misc/OutputDeviceError.h"
|
|
|
|
|
|
|
|
|
|
namespace UE::LowLevelTests
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class FCheckScopeOutputDeviceError : public FOutputDeviceError
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FCheckScopeOutputDeviceError(FOutputDeviceError* Error, const ANSICHAR* Msg)
|
|
|
|
|
: DeviceError(Error)
|
|
|
|
|
, ExpectedMsg(Msg)
|
|
|
|
|
, Count(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void HandleError() override
|
|
|
|
|
{
|
|
|
|
|
if (DeviceError)
|
|
|
|
|
{
|
|
|
|
|
DeviceError->HandleError();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Serialize(const TCHAR* V, ELogVerbosity::Type Verbosity, const FName& Category) override
|
|
|
|
|
{
|
|
|
|
|
if (ExpectedMsg)
|
|
|
|
|
{
|
|
|
|
|
auto Str = StringCast<TCHAR>(ExpectedMsg);
|
|
|
|
|
auto Found = FPlatformString::Strstr(V, Str.Get());
|
|
|
|
|
if (Found)
|
|
|
|
|
{
|
|
|
|
|
++Count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++Count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetDeviceError(FOutputDeviceError* Error)
|
|
|
|
|
{
|
|
|
|
|
DeviceError = Error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FOutputDeviceError* GetDeviceError() const
|
|
|
|
|
{
|
|
|
|
|
return DeviceError;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GetCount() { return Count; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
FOutputDeviceError* DeviceError;
|
|
|
|
|
const ANSICHAR* ExpectedMsg;
|
|
|
|
|
int Count;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FCheckScope::FCheckScope(const ANSICHAR* Msg)
|
|
|
|
|
: DeviceError(new FCheckScopeOutputDeviceError(GError, Msg))
|
2022-12-07 13:40:53 -05:00
|
|
|
#if !UE_BUILD_SHIPPING
|
2022-10-13 11:24:15 -04:00
|
|
|
, bIgnoreDebugger(GIgnoreDebugger)
|
2022-12-07 13:40:53 -05:00
|
|
|
#else
|
|
|
|
|
, bIgnoreDebugger(false)
|
|
|
|
|
#endif
|
2023-01-19 11:38:44 -05:00
|
|
|
, bCriticalError(GIsCriticalError)
|
2022-10-13 11:24:15 -04:00
|
|
|
{
|
2022-12-07 13:40:53 -05:00
|
|
|
#if !UE_BUILD_SHIPPING
|
2022-10-13 11:24:15 -04:00
|
|
|
GIgnoreDebugger = true;
|
2022-12-07 13:40:53 -05:00
|
|
|
#endif
|
2022-10-13 11:24:15 -04:00
|
|
|
GError = DeviceError;
|
2023-01-19 11:38:44 -05:00
|
|
|
GIsCriticalError = true; //set to true to disable printf of error message which causes Horde to flag the lines as an error
|
2022-10-13 11:24:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FCheckScope::FCheckScope()
|
|
|
|
|
: FCheckScope(nullptr)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FCheckScope::~FCheckScope()
|
|
|
|
|
{
|
2022-12-07 13:40:53 -05:00
|
|
|
#if !UE_BUILD_SHIPPING
|
2022-10-13 11:24:15 -04:00
|
|
|
GIgnoreDebugger = bIgnoreDebugger;
|
2022-12-07 13:40:53 -05:00
|
|
|
#endif
|
2022-10-13 11:24:15 -04:00
|
|
|
GError = DeviceError->GetDeviceError();
|
2023-01-19 11:38:44 -05:00
|
|
|
GIsCriticalError = bCriticalError;
|
2022-10-13 11:24:15 -04:00
|
|
|
delete DeviceError;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
FCheckScope::GetCount()
|
|
|
|
|
{
|
|
|
|
|
return DeviceError->GetCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|