aboutsummaryrefslogtreecommitdiff
path: root/src/zenmaster-test/zenmaster-test.cpp
blob: 7511d6b4a7c8ec0a3947468dc9da05cc910b291e (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright Epic Games, Inc. All Rights Reserved.

#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING

#include <zenbase/refcount.h>
#include <zencore/compactbinary.h>
#include <zencore/compactbinarybuilder.h>
#include <zencore/compactbinarypackage.h>
#include <zencore/compress.h>
#include <zencore/except.h>
#include <zencore/fmtutils.h>
#include <zencore/logging.h>
#include <zencore/memoryview.h>
#include <zencore/scopeguard.h>
#include <zencore/stream.h>
#include <zencore/string.h>
#include <zencore/testutils.h>
#include <zencore/timer.h>
#include <zencore/xxhash.h>
#include <zenutil/logging/testformatter.h>
#include <zenutil/zenserverprocess.h>

#include <atomic>
#include <filesystem>
#include <map>
#include <random>
#include <span>
#include <thread>
#include <typeindex>
#include <unordered_map>

#include <zencore/memory/newdelete.h>

//////////////////////////////////////////////////////////////////////////

#if ZEN_WITH_TESTS
#	define ZEN_TEST_WITH_RUNNER 1
#	include <zencore/testing.h>
#endif

using namespace std::literals;

#if !ZEN_WITH_TESTS
int
main()
{
}
#else
zen::ZenServerEnvironment TestEnv;

int
main(int argc, char** argv)
{
	using namespace std::literals;
	using namespace zen;

#	if ZEN_PLATFORM_LINUX
	IgnoreChildSignals();
#	endif

	zen::TraceInit("zenmaster-test");
	zen::logging::InitializeLogging();

	zen::logging::SetLogLevel(zen::logging::level::Debug);
	spdlog::set_formatter(std::make_unique<zen::logging::full_test_formatter>("test", std::chrono::system_clock::now()));

	std::filesystem::path ProgramBaseDir = GetRunningExecutablePath().parent_path();
	std::filesystem::path TestBaseDir	 = std::filesystem::current_path() / ".test";

	// This is pretty janky because we're passing most of the options through to the test
	// framework, so we can't just use cxxopts (I think). This should ideally be cleaned up
	// somehow in the future

	std::string ServerClass;

	for (int i = 1; i < argc; ++i)
	{
		if (argv[i] == "--http"sv)
		{
			if ((i + 1) < argc)
			{
				ServerClass = argv[++i];
			}
		}
	}

	TestEnv.InitializeForTest(ProgramBaseDir, TestBaseDir, ServerClass);

	ZEN_INFO("Running tests...(base dir: '{}')", TestBaseDir);

	zen::testing::TestRunner Runner;
	Runner.ApplyCommandLine(argc, argv);

	return Runner.Run();
}
#endif