Browse Source

Add loading capabilities for acedia v0.1.dev2

In new Acedia version we must create `CoreService` and register
commands.
new
Anton Tarasenko 4 years ago
parent
commit
53f16e794c
  1. 81
      sources/Packages.uc
  2. 9
      sources/TestingListener_AcediaLauncher.uc

81
sources/Packages.uc

@ -66,8 +66,9 @@ private final function BootUp()
{ {
local int i; local int i;
local class<_manifest> nextManifest; local class<_manifest> nextManifest;
_ = Spawn(class'Global');
// Load core // Load core
Spawn(class'CoreService');
_ = class'Global'.static.GetInstance();
nextManifest = LoadManifestClass(corePackage); nextManifest = LoadManifestClass(corePackage);
if (nextManifest == none) if (nextManifest == none)
{ {
@ -91,7 +92,7 @@ private final function BootUp()
LoadManifest(nextManifest); LoadManifest(nextManifest);
} }
// Inject broadcast handler // Inject broadcast handler
InjectBroadcastHandler(); // TODO: move this to 'SideEffect' mechanic InjectBroadcastHandler();
} }
private final function RunStartUpTests() private final function RunStartUpTests()
@ -103,7 +104,7 @@ private final function RunStartUpTests()
testService.FilterByName(testService.requiredName); testService.FilterByName(testService.requiredName);
} }
if (testService.filterTestsByGroup) { if (testService.filterTestsByGroup) {
testService.FilterByName(testService.requiredGroup); testService.FilterByGroup(testService.requiredGroup);
} }
if (testService.Run()) if (testService.Run())
{ {
@ -125,40 +126,86 @@ private final function class<_manifest> LoadManifestClass(string packageName)
private final function LoadManifest(class<_manifest> manifestClass) private final function LoadManifest(class<_manifest> manifestClass)
{ {
local int i; local int i;
// Load alias sources
for (i = 0; i < manifestClass.default.aliasSources.length; i += 1) for (i = 0; i < manifestClass.default.aliasSources.length; i += 1)
{ {
if (manifestClass.default.aliasSources[i] == none) continue; if (manifestClass.default.aliasSources[i] == none) continue;
Spawn(manifestClass.default.aliasSources[i]); //Spawn(manifestClass.default.aliasSources[i]);
_.memory.Allocate(manifestClass.default.aliasSources[i]);
} }
// Enable features LaunchServicesAndFeatures(manifestClass);
if (class'Commands'.static.IsEnabled()) {
RegisterCommands(manifestClass);
}
for (i = 0; i < manifestClass.default.testCases.length; i += 1)
{
class'TestingService'.static
.RegisterTestCase(manifestClass.default.testCases[i]);
}
}
private final function RegisterCommands(class<_manifest> manifestClass)
{
local int i;
local Commands commandsFeature;
commandsFeature = Commands(class'Commands'.static.GetInstance());
for (i = 0; i < manifestClass.default.commands.length; i += 1)
{
if (manifestClass.default.commands[i] == none) continue;
commandsFeature.RegisterCommand(manifestClass.default.commands[i]);
}
}
private final function LaunchServicesAndFeatures(class<_manifest> manifestClass)
{
local int i;
local bool packageFeaturesAreUsed;
for (i = 0; i < manifestClass.default.features.length; i += 1) for (i = 0; i < manifestClass.default.features.length; i += 1)
{ {
if (manifestClass.default.features[i] == none) continue; if (manifestClass.default.features[i] == none) continue;
if (manifestClass.default.features[i].static.IsAutoEnabled()) { if (manifestClass.default.features[i].static.IsAutoEnabled())
manifestClass.default.features[i].static.EnableMe(); {
packageFeaturesAreUsed = true;
break;
} }
} }
// Load tests cases // Services
for (i = 0; i < manifestClass.default.testCases.length; i += 1) for (i = 0; i < manifestClass.default.services.length; i += 1)
{ {
class'TestingService'.static if (manifestClass.default.services[i] == none) continue;
.RegisterTestCase(manifestClass.default.testCases[i]); manifestClass.default.services[i].static.Require();
}
// Features
for (i = 0; i < manifestClass.default.features.length; i += 1)
{
if (manifestClass.default.features[i] == none) continue;
if (manifestClass.default.features[i].static.IsAutoEnabled()) {
manifestClass.default.features[i].static.EnableMe();
}
} }
} }
private final function InjectBroadcastHandler() private final function InjectBroadcastHandler()
{ {
local BroadcastHandler ourBroadcastHandler; local BroadcastEventsObserver ourBroadcastHandler;
if (level == none || level.game == none) return; local BroadcastEventsObserver.InjectionLevel injectionLevel;
injectionLevel = class'BroadcastEventsObserver'.default.usedInjectionLevel;
ourBroadcastHandler = Spawn(class'BroadcastHandler'); if (level == none || level.game == none) return;
if (injectionLevel == BHIJ_None) return;
ourBroadcastHandler = Spawn(class'BroadcastEventsObserver');
if (injectionLevel == BHIJ_Registered)
{
level.game.broadcastHandler
.RegisterBroadcastHandler(ourBroadcastHandler);
return;
}
// Here `injectionLevel == BHIJ_Root` holds.
// Swap out level's first handler with ours // Swap out level's first handler with ours
// (needs to be done for both actor reference and it's class) // (needs to be done for both actor reference and it's class)
ourBroadcastHandler.nextBroadcastHandler = level.game.broadcastHandler; ourBroadcastHandler.nextBroadcastHandler = level.game.broadcastHandler;
ourBroadcastHandler.nextBroadcastHandlerClass = level.game.broadcastClass; ourBroadcastHandler.nextBroadcastHandlerClass = level.game.broadcastClass;
level.game.broadcastHandler = ourBroadcastHandler; level.game.broadcastHandler = ourBroadcastHandler;
level.game.broadcastClass = class'BroadcastHandler'; level.game.broadcastClass = class'BroadcastEventsObserver';
} }
// Acedia is only able to run in a server mode right now, // Acedia is only able to run in a server mode right now,

9
sources/TestingListener_AcediaLauncher.uc

@ -26,14 +26,15 @@ static function TestingEnded(
array<TestCaseSummary> results) array<TestCaseSummary> results)
{ {
local int i; local int i;
local string nextLine; local MutableText nextLine;
local array<string> textSummary; local array<string> textSummary;
nextLine = __().text.Empty();
textSummary = class'TestCaseSummary'.static.GenerateStringSummary(results); textSummary = class'TestCaseSummary'.static.GenerateStringSummary(results);
for (i = 0; i < textSummary.length; i += 1) for (i = 0; i < textSummary.length; i += 1)
{ {
nextLine = _().text.ConvertString( textSummary[i], nextLine.Clear();
STRING_Formatted, STRING_Plain); nextLine.AppendFormattedString(textSummary[i]);
Log(nextLine); Log(nextLine.ToPlainString());
} }
// No longer need to listen to testing events // No longer need to listen to testing events
SetActive(false); SetActive(false);