Files
UnrealEngineUWP/Engine/Source/Developer/LowLevelTestsRunner/Private/TestCommon/Initialization.cpp
chris constantinescu c45d474014 UnrealVS - do not project prepend project path for Editor configuration in the case of test targets
- Project generation will add a new IsTestTarget property in the "Globals" property group section of the project file for explicit test target projects
- UnrealVS checks for this property and does not change the command line for test targets
- TestRunner removes all project argument logic - that can be passed after --extra-args using -project="Path/To/*.uproject" and/or -projectdir="Path/To/Project"
- OSS and Online global handlers, which occur during the Catch2 session, will read project name and/or directory using SetProjectNameAndDirectory from TestCommon/Initialization.h
#jira UE-189840

[CL 26688348 by chris constantinescu in ue5-main branch]
2023-07-28 17:20:05 -04:00

126 lines
2.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "TestCommon/Initialization.h"
#include "TestCommon/CoreUtilities.h"
#include "TestCommon/CoreUObjectUtilities.h"
#include "TestCommon/EngineUtilities.h"
#include "Containers/UnrealString.h"
#include "GenericPlatform/GenericPlatformFile.h"
#include "HAL/PlatformFileManager.h"
#include "Misc/CommandLine.h"
#include "Misc/DelayedAutoRegister.h"
#include "Misc/Paths.h"
static IPlatformFile* DefaultPlatformFile;
void InitAllThreadPoolsEditorEx(bool MultiThreaded)
{
#if WITH_EDITOR
InitEditorThreadPools();
#endif // WITH_EDITOR
InitAllThreadPools(MultiThreaded);
}
void InitStats()
{
#if STATS
FThreadStats::StartThread();
#endif // #if STATS
FDelayedAutoRegisterHelper::RunAndClearDelayedAutoRegisterDelegates(EDelayedRegisterRunPhase::StatSystemReady);
}
void UsePlatformFileStubIfRequired()
{
#if WITH_ENGINE && UE_LLT_USE_PLATFORM_FILE_STUB
if (IPlatformFile* WrapperFile = FPlatformFileManager::Get().GetPlatformFile(TEXT("PlatformFileStub")))
{
IPlatformFile* CurrentPlatformFile = &FPlatformFileManager::Get().GetPlatformFile();
WrapperFile->Initialize(CurrentPlatformFile, TEXT(""));
FPlatformFileManager::Get().SetPlatformFile(*WrapperFile);
}
#endif // WITH_ENGINE && UE_LLT_USE_PLATFORM_FILE_STUB
}
void SaveDefaultPlatformFile()
{
DefaultPlatformFile = &FPlatformFileManager::Get().GetPlatformFile();
}
void UseDefaultPlatformFile()
{
FPlatformFileManager::Get().SetPlatformFile(*DefaultPlatformFile);
}
void SetProjectNameAndDirectory()
{
FString ProjectFileOrName;
FString ProjectDirOverride;
bool bIsProjectNamePassed = false;
FParse::Value(FCommandLine::Get(), TEXT("-project="), ProjectFileOrName);
if (!ProjectFileOrName.IsEmpty())
{
bIsProjectNamePassed = !ProjectFileOrName.EndsWith(TEXT(".uproject"));
}
FParse::Value(FCommandLine::Get(), TEXT("-projectdir="), ProjectDirOverride);
if (!ProjectDirOverride.IsEmpty())
{
if (!ProjectDirOverride.EndsWith(TEXT("/")))
{
ProjectDirOverride.Append(TEXT("/"));
}
}
if (!bIsProjectNamePassed && ProjectDirOverride.IsEmpty() && !ProjectFileOrName.IsEmpty())
{
ProjectDirOverride = FPaths::GetPath(ProjectFileOrName);
}
if (!ProjectDirOverride.IsEmpty())
{
FPaths::NormalizeDirectoryName(ProjectDirOverride);
FGenericPlatformMisc::SetOverrideProjectDir(ProjectDirOverride);
}
}
void InitAll(bool bAllowLogging, bool bMultithreaded)
{
SaveDefaultPlatformFile();
UsePlatformFileStubIfRequired();
InitAllThreadPools(bMultithreaded);
#if WITH_ENGINE
InitAsyncQueues();
#endif // WITH_ENGINE
InitTaskGraph();
#if WITH_ENGINE
InitGWarn();
InitEngine();
#endif // WITH_ENGINE
#if WITH_EDITOR
InitDerivedDataCache();
InitSlate();
InitForWithEditorOnlyData();
InitEditor();
#endif // WITH_EDITOR
#if WITH_COREUOBJECT
InitCoreUObject();
#endif
GIsRunning = true;
}
void CleanupAll()
{
#if WITH_ENGINE
CleanupEngine();
#endif
#if WITH_COREUOBJECT
CleanupCoreUObject();
#endif
CleanupAllThreadPools();
CleanupTaskGraph();
}