Files
Ben Marsh c4d483b01a Horde: Fix event matcher for editor exit codes not matching negative values correctly.
#preflight none

[CL 23099958 by Ben Marsh in ue5-main branch]
2022-11-11 12:08:08 -05:00

45 lines
935 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]|(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;
}
}
}