SelfTests: Removed the unneeded cSelfTests class.
This commit is contained in:
parent
aa4b3ebf2f
commit
36eefbf0f2
@ -63,7 +63,6 @@ SET (SRCS
|
||||
RCONServer.cpp
|
||||
Root.cpp
|
||||
Scoreboard.cpp
|
||||
SelfTests.cpp
|
||||
Server.cpp
|
||||
SetChunkData.cpp
|
||||
SpawnPrepare.cpp
|
||||
@ -140,7 +139,6 @@ SET (HDRS
|
||||
RCONServer.h
|
||||
Root.h
|
||||
Scoreboard.h
|
||||
SelfTests.h
|
||||
Server.h
|
||||
SetChunkData.h
|
||||
SettingsRepositoryInterface.h
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "PieceGenerator.h"
|
||||
#include "../SelfTests.h"
|
||||
#include "VerticalStrategy.h"
|
||||
#include "VerticalLimit.h"
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "Globals.h"
|
||||
#include "PrefabPiecePool.h"
|
||||
#include "../Bindings/LuaState.h"
|
||||
#include "SelfTests.h"
|
||||
#include "WorldStorage/SchematicFileSerializer.h"
|
||||
#include "VerticalStrategy.h"
|
||||
#include "../StringCompression.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "Globals.h"
|
||||
#include "Network.h"
|
||||
#include "event2/util.h"
|
||||
#include "../SelfTests.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <IPHlpApi.h>
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "IniFile.h"
|
||||
#include "SettingsRepositoryInterface.h"
|
||||
#include "OverridesSettingsRepository.h"
|
||||
#include "SelfTests.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#include <iostream>
|
||||
@ -128,11 +127,6 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
|
||||
LOG("from commit id: " BUILD_COMMIT_ID " built at: " BUILD_DATETIME);
|
||||
#endif
|
||||
|
||||
// Run the self-tests registered previously via cSelfTests::Register():
|
||||
#ifdef SELF_TEST
|
||||
cSelfTests::ExecuteAll();
|
||||
#endif
|
||||
|
||||
cDeadlockDetect dd;
|
||||
auto BeginTime = std::chrono::steady_clock::now();
|
||||
|
||||
|
@ -1,71 +0,0 @@
|
||||
|
||||
// SelfTests.h
|
||||
|
||||
// Implements the cSelfTests class representing the singleton used for registering self-tests
|
||||
// This class is only declared if SELF_TEST macro is defined.
|
||||
|
||||
#include "Globals.h"
|
||||
#include "SelfTests.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SELF_TEST
|
||||
cSelfTests::cSelfTests(void):
|
||||
m_AllowRegistering(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cSelfTests & cSelfTests::Get(void)
|
||||
{
|
||||
static cSelfTests singleton;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cSelfTests::Register(cSelfTests::SelfTestFunction a_FnToExecute, const AString & a_TestName)
|
||||
{
|
||||
ASSERT(Get().m_AllowRegistering);
|
||||
Get().m_SelfTests.push_back(std::make_pair(a_FnToExecute, a_TestName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cSelfTests::ExecuteAll(void)
|
||||
{
|
||||
Get().m_AllowRegistering = false;
|
||||
LOG("--- Performing self-tests ---");
|
||||
for (auto & test: Get().m_SelfTests)
|
||||
{
|
||||
LOG("Performing self-test: %s", test.second.c_str());
|
||||
try
|
||||
{
|
||||
test.first();
|
||||
}
|
||||
catch (const std::exception & exc)
|
||||
{
|
||||
LOGWARNING("Exception in test %s: %s", test.second.c_str(), exc.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LOGWARNING("Unknown exception in test %s", test.second.c_str());
|
||||
}
|
||||
} // for test - m_SelfTests[]
|
||||
LOG("--- Self-tests finished ---");
|
||||
}
|
||||
|
||||
#endif // SELF_TEST
|
||||
|
||||
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
|
||||
// SelfTests.h
|
||||
|
||||
// Declares the cSelfTests class representing the singleton used for registering self-tests
|
||||
// This class is only declared if SELF_TEST macro is defined.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SELF_TEST
|
||||
/** Singleton containing registered self-tests.
|
||||
Used to schedule self-tests to run after the logging framework is initialized (#2228). */
|
||||
class cSelfTests
|
||||
{
|
||||
public:
|
||||
/** Returns the singleton instance of this class. */
|
||||
static cSelfTests & Get(void);
|
||||
|
||||
// typedef void (* SelfTestFunction)(void);
|
||||
typedef std::function<void(void)> SelfTestFunction;
|
||||
|
||||
/** Registers a self-test to be executed once the logging framework is initialized. */
|
||||
static void Register(SelfTestFunction a_FnToExecute, const AString & a_TestName);
|
||||
|
||||
/** Executes all the registered self-tests. */
|
||||
static void ExecuteAll(void);
|
||||
|
||||
protected:
|
||||
typedef std::vector<std::pair<SelfTestFunction, AString>> SelfTestFunctions;
|
||||
|
||||
/** Functions (registered self-tests) to call once the logging framework is initialized. */
|
||||
SelfTestFunctions m_SelfTests;
|
||||
|
||||
/** If true, tests may be registered. Set to false once the tests are executed, to detect tests that are registered too late. */
|
||||
bool m_AllowRegistering;
|
||||
|
||||
|
||||
cSelfTests(void);
|
||||
};
|
||||
#endif // SELF_TEST
|
||||
|
||||
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "BlockInfo.h"
|
||||
#include "SelfTests.h"
|
||||
#include "Bindings.h"
|
||||
#include "Bindings/DeprecatedBindings.h"
|
||||
#include "Bindings/LuaJson.h"
|
||||
@ -272,30 +271,3 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
|
||||
|
||||
|
||||
|
||||
|
||||
cSelfTests::cSelfTests(void):
|
||||
m_AllowRegistering(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cSelfTests & cSelfTests::Get(void)
|
||||
{
|
||||
static cSelfTests singleton;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cSelfTests::Register(cSelfTests::SelfTestFunction a_TestFn, const AString & a_TestName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user