BuildGraph: Reformat output from Docker to allow regular pattern matchers to work correctly, and add an MSTest event matcher.

#preflight none

[CL 20580176 by Ben Marsh in ue5-main branch]
This commit is contained in:
Ben Marsh
2022-06-09 13:18:32 -04:00
parent 378ddb20ea
commit 3e3deac9d0
7 changed files with 110 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ using System.Xml;
using AutomationTool;
using UnrealBuildBase;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace AutomationTool.Tasks
{
@@ -172,10 +173,14 @@ namespace AutomationTool.Tasks
}
string WorkingDir = isStagingEnabled ? StagingDir.FullName : BaseDir.FullName;
await SpawnTaskBase.ExecuteAsync("docker", Arguments.ToString(), EnvVars: EnvVars, WorkingDir: WorkingDir);
await SpawnTaskBase.ExecuteAsync("docker", Arguments.ToString(), EnvVars: EnvVars, WorkingDir: WorkingDir, SpewFilterCallback: FilterOutput);
}
}
static Regex FilterOutputPattern = new Regex(@"^#\d+ (?:\d+\.\d+ )?");
static string FilterOutput(string Line) => FilterOutputPattern.Replace(Line, "");
/// <summary>
/// Output this task out to an XML writer.
/// </summary>

View File

@@ -71,7 +71,7 @@ namespace AutomationTool.Tasks
/// <summary>
/// Execute a command
/// </summary>
protected static Task<IProcessResult> ExecuteAsync(string Exe, string Arguments, string WorkingDir = null, Dictionary<string, string> EnvVars = null, bool LogOutput = true, int ErrorLevel = 1, string Input = null)
protected static Task<IProcessResult> ExecuteAsync(string Exe, string Arguments, string WorkingDir = null, Dictionary<string, string> EnvVars = null, bool LogOutput = true, int ErrorLevel = 1, string Input = null, ProcessResult.SpewFilterCallbackType SpewFilterCallback = null)
{
if (WorkingDir != null)
{
@@ -84,7 +84,7 @@ namespace AutomationTool.Tasks
Options &= ~CommandUtils.ERunOptions.AllowSpew;
}
IProcessResult Result = CommandUtils.Run(Exe, Arguments, Env: EnvVars, WorkingDir: WorkingDir, Options: Options, Input: Input);
IProcessResult Result = CommandUtils.Run(Exe, Arguments, Env: EnvVars, WorkingDir: WorkingDir, Options: Options, Input: Input, SpewFilterCallback: SpewFilterCallback);
if (Result.ExitCode < 0 || Result.ExitCode >= ErrorLevel)
{
throw new AutomationException("{0} terminated with an exit code indicating an error ({1})", Path.GetFileName(Exe), Result.ExitCode);