Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/AutomationUtils/Matchers/ExitCodeEventMatcher.cs
Ben Marsh 7514d30d9b Move the remaining log matchers into AutomationUtils.
#preflight 6286a7049016c6dd899f2fb8

[CL 20286961 by Ben Marsh in ue5-main branch]
2022-05-19 16:29:37 -04:00

53 lines
1.1 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EpicGames.Core;
using Microsoft.Extensions.Logging;
#nullable enable
namespace AutomationUtils.Matchers
{
/// <summary>
/// Matcher for editor/UAT instances exiting with an error
/// </summary>
class ExitCodeEventMatcher : ILogEventMatcher
{
public LogEventMatch? Match(ILogCursor cursor)
{
int numLines = 0;
for (; ; )
{
if (cursor.IsMatch(numLines, "Editor terminated with exit code [1-9]"))
{
numLines++;
}
else if (cursor.IsMatch(numLines, "AutomationTool exiting with ExitCode=[1-9]"))
{
numLines++;
}
else if (cursor.IsMatch(numLines, "BUILD FAILED"))
{
numLines++;
}
else if (cursor.IsMatch(numLines, "(Error executing.+)(tool returned code)(.+)"))
{
numLines++;
}
else
{
break;
}
}
if (numLines > 0)
{
LogEventBuilder builder = new LogEventBuilder(cursor);
builder.MoveNext(numLines - 1);
return builder.ToMatch(LogEventPriority.Low, LogLevel.Error, KnownLogEvents.ExitCode);
}
return null;
}
}
}