Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/AutomationUtils/Matchers/ExitCodeEventMatcher.cs
Ben Marsh 878f74458e Horde: Use long-lived regex instances for matching patterns.
#preflight 62963a2b95336ad2bfbfe846

[CL 20438090 by Ben Marsh in ue5-main branch]
2022-05-31 12:02:25 -04:00

45 lines
989 B
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EpicGames.Core;
using Microsoft.Extensions.Logging;
using System.Text.RegularExpressions;
#nullable enable
namespace AutomationUtils.Matchers
{
/// <summary>
/// Matcher for editor/UAT instances exiting with an error
/// </summary>
class ExitCodeEventMatcher : ILogEventMatcher
{
static readonly Regex s_pattern = new Regex(
@"Editor terminated with exit code [1-9]|AutomationTool exiting with ExitCode=[1-9]|BUILD FAILED|(Error executing.+)(tool returned code)(.+)");
public LogEventMatch? Match(ILogCursor cursor)
{
int numLines = 0;
for (; ; )
{
if (cursor.IsMatch(numLines, s_pattern))
{
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;
}
}
}