Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/AutomationUtils/Matchers/ExitCodeEventMatcher.cs
ben marsh 5a81e8dca5 AutomationTool: Flag "RunUBT ERROR:" messages as an ignorable exit code error.
[CL 34563686 by ben marsh in ue5-main branch]
2024-06-21 11:15:54 -04:00

47 lines
977 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)(.+)" +
@"|\s*RunU[AB]T ERROR:");
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;
}
}
}