blob: ecbe39f90c9ba8e8089cd74cef276ea5cf7dcf6c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include <zencore/thread.h>
#include <spdlog/spdlog.h>
#include <filesystem>
class ZenTestEnvironment
{
public:
ZenTestEnvironment();
~ZenTestEnvironment();
void Initialize(std::filesystem::path ProgramBaseDir, std::filesystem::path TestBaseDir);
std::filesystem::path CreateNewTestDir();
std::filesystem::path ProgramBaseDir() const { return m_ProgramBaseDir; }
std::filesystem::path RootDir(std::string_view Path);
bool IsInitialized() const { return m_IsInitialized; }
private:
std::filesystem::path m_ProgramBaseDir;
std::filesystem::path m_TestBaseDir;
bool m_IsInitialized = false;
};
struct ZenServerInstance
{
ZenServerInstance(ZenTestEnvironment& TestEnvironment);
~ZenServerInstance();
void SignalShutdown() { m_ShutdownEvent.Set(); }
void WaitUntilReady() { m_ReadyEvent.Wait(); }
void EnableTermination() { m_Terminate = true; }
void SetTestDir(std::filesystem::path TestDir)
{
ZEN_ASSERT(!m_Process.IsValid());
m_TestDir = TestDir;
}
void SpawnServer(int BasePort);
private:
ZenTestEnvironment& m_Env;
zen::Process m_Process;
zen::Event m_ReadyEvent;
zen::Event m_ShutdownEvent;
bool m_Terminate = false;
std::filesystem::path m_TestDir;
};
|