2021-09-29 15:50:57 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#define CATCH_CONFIG_RUNNER
|
|
|
|
|
|
|
|
|
|
#include "TestRunner.h"
|
|
|
|
|
#include "TestHarness.h"
|
2021-10-07 04:08:53 -04:00
|
|
|
#include "HAL/PlatformTLS.h"
|
2021-09-29 15:50:57 -04:00
|
|
|
|
|
|
|
|
int RunTests(int argc, const char* argv[])
|
|
|
|
|
{
|
2021-10-07 04:08:53 -04:00
|
|
|
// remember thread id of the main thread
|
|
|
|
|
GGameThreadId = FPlatformTLS::GetCurrentThreadId();
|
|
|
|
|
GIsGameThreadIdInitialized = true;
|
|
|
|
|
|
2021-10-15 12:17:53 -04:00
|
|
|
#ifdef SLEEP_ON_INIT
|
|
|
|
|
// Sleep to allow sync with Gauntlet
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-09-29 15:50:57 -04:00
|
|
|
Setup();
|
|
|
|
|
|
2021-10-15 12:17:53 -04:00
|
|
|
//Read command-line from file (if any). Some platforms do this earlier.
|
|
|
|
|
#ifndef PLATFORM_SKIP_ADDITIONAL_ARGS
|
2021-09-29 15:50:57 -04:00
|
|
|
int ArgsOverrideNum = 0;
|
|
|
|
|
const char** ArgsOverride = ReadAndAppendAdditionalArgs(GetProcessExecutablePath(), &ArgsOverrideNum, argv, argc);
|
|
|
|
|
if (ArgsOverride != nullptr && ArgsOverrideNum > 1)
|
|
|
|
|
{
|
|
|
|
|
argc = ArgsOverrideNum;
|
|
|
|
|
argv = ArgsOverride;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int CatchArgc;
|
|
|
|
|
TUniquePtr<const char* []> CatchArgv = MakeUnique<const char* []>(argc);
|
|
|
|
|
|
|
|
|
|
// Everything past a "--" argument, if present, is not sent to the catch test runner.
|
|
|
|
|
for (CatchArgc = 0; CatchArgc < argc; ++CatchArgc)
|
|
|
|
|
{
|
|
|
|
|
if (std::strcmp(argv[CatchArgc], "--") == 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
CatchArgv.Get()[CatchArgc] = argv[CatchArgc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// By default don't wait for input
|
|
|
|
|
bool bWaitForInputToTerminate = false;
|
|
|
|
|
|
|
|
|
|
for (int i = CatchArgc; i < argc; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (std::strcmp(argv[i], "--wait") == 0)
|
|
|
|
|
{
|
|
|
|
|
bWaitForInputToTerminate = true;
|
|
|
|
|
}
|
|
|
|
|
else if (std::strcmp(argv[i], "--no-wait") == 0)
|
|
|
|
|
{
|
|
|
|
|
bWaitForInputToTerminate = false;
|
|
|
|
|
}
|
|
|
|
|
if (std::strcmp(argv[i], "--no-log") == 0)
|
|
|
|
|
{
|
|
|
|
|
bGAllowLogging = false;
|
|
|
|
|
}
|
|
|
|
|
if (std::strcmp(argv[i], "--no-mt") == 0)
|
|
|
|
|
{
|
|
|
|
|
bMultithreaded = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear after init so that in windows it is actually clear during the test.
|
|
|
|
|
if (bGAllowLogging)
|
|
|
|
|
{
|
|
|
|
|
FCommandLine::Set(TEXT(""));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FCommandLine::Set(TEXT(R"(-LogCmds="global off")"));
|
|
|
|
|
FLogSuppressionInterface::Get().ProcessConfigAndCommandLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SessionResult = 0;
|
|
|
|
|
{
|
|
|
|
|
TGuardValue<bool> CatchRunning(bCatchIsRunning, true);
|
|
|
|
|
SessionResult = Catch::Session().run(CatchArgc, CatchArgv.Get());
|
|
|
|
|
CatchArgv.Reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Teardown();
|
|
|
|
|
|
2021-10-15 12:17:53 -04:00
|
|
|
#if PLATFORM_DESKTOP
|
2021-09-29 15:50:57 -04:00
|
|
|
if (bWaitForInputToTerminate)
|
|
|
|
|
{
|
|
|
|
|
std::cout << "Press enter to exit..." << std::endl;
|
|
|
|
|
std::cin.ignore();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return SessionResult;
|
|
|
|
|
};
|