Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/LowLevelTests/Utility/LowLevelTests.LogParser.cs
chris constantinescu 911e95a6d0 Low level tests - platform fixes and presubmit default compilation to prevent breaking
- Addressed remaining NDA platform code that was present in public facing folders
- Compile LowLevelTests target by default on presubmits and incremental builds for Main and 5.0
- Add dummy test on LowLevelTetsts and run it on consoles daily - this test is called "Self" and it's a sanity check run for Catch2
- Fixed Switch indefinite hang - Self test run successfully on this console
- Added IRunningStateOptions to control app run state: startup and check running state options
- AudioUnitTests run successfully on XboxOneGDK and XSX
- XSX Self and AudioUnitTests run successfully but XSX reports VideoEscape errors - JIRA UE-131334

#jira UEENGQA-52681, UE-127449
#rb Jerome.Delattre

#ROBOMERGE-AUTHOR: chris.constantinescu
#ROBOMERGE-SOURCE: CL 17830364 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v881-17767770)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 17830380 by chris constantinescu in ue5-release-engine-test branch]
2021-10-15 12:17:53 -04:00

135 lines
3.4 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using Gauntlet;
using System.Text.RegularExpressions;
namespace LowLevelTests
{
public class LowLevelTestsLogParser : UnrealLogParser
{
public class CatchTestResults
{
public bool Passed = false;
public CatchAssertionResult Assertions;
public CatchTestCaseResult TestCases;
public CatchTestResults()
{
Assertions = new CatchAssertionResult();
TestCases = new CatchTestCaseResult();
}
}
public class CatchTestCaseResult
{
public string TotalCases;
public string Passed;
public string Failed;
public CatchTestCaseResult()
{
TotalCases = "";
Passed = "";
Failed = "";
}
}
public class CatchAssertionResult
{
public string TotalAssertions;
public string Passed;
public string Failed;
public CatchAssertionResult()
{
TotalAssertions = "";
Passed = "";
Failed = "";
}
}
internal class ParsePatterns
{
internal const string AllCatchTestPassed = @"All tests passed\s\((?<assertions>[\w\d]+)\sassertion[s]?\sin\s(?<testcases>[\w\d]+)\stest\scase[s]?.*\)";
internal const string CatchTestCaseResults = @"test\scase[s]?\:\s+(?<totalcases>[\d]+)\s+\|\s+(?<passed>[\d]+)\s+passed\s+\|\s+(?<failed>[\d]+)\s+failed";
internal const string CatchTestAssertionResults = @"assertion[s]?\:\s+(?<totalcases>[\d]+)\s+\|\s+(?<passed>[\d]+)\s+passed\s+\|\s+(?<failed>[\d]+)\s+failed";
internal const string CatchThrowException = "Catch will terminate because it needed to throw an exception.";
}
public LowLevelTestsLogParser(string InContent)
: base(InContent)
{
}
public CatchTestResults GetCatchTestResults()
{
var TestResults = new CatchTestResults { };
if (Regex.Matches(Content, ParsePatterns.CatchThrowException).Count > 0)
{
TestResults.Passed = false;
}
var AllCatchTestPassesPattern = ParsePatterns.AllCatchTestPassed;
MatchCollection mCollection = Regex.Matches(Content, AllCatchTestPassesPattern);
//If all the tests pass, report it and return.
foreach (Match aMatch in mCollection)
{
if (aMatch.Success)
{
TestResults.Passed = true;
TestResults.Assertions = new CatchAssertionResult
{
TotalAssertions = aMatch.Groups["assertions"].ToString()
};
TestResults.TestCases = new CatchTestCaseResult
{
TotalCases = aMatch.Groups["testcases"].ToString()
};
return TestResults;
}
}
// If we did not find any matching test passed string from catch, check to see test results of pass/fail were logged.
MatchCollection rCollection = Regex.Matches(Content, ParsePatterns.CatchTestCaseResults);
foreach (Match aMatch in rCollection)
{
if (aMatch.Success)
{
TestResults.Passed = false;
TestResults.TestCases = new CatchTestCaseResult()
{
TotalCases = aMatch.Groups["totalcases"].ToString(),
Passed = aMatch.Groups["passed"].ToString(),
Failed = aMatch.Groups["failed"].ToString()
};
}
}
MatchCollection aCollection = Regex.Matches(Content, ParsePatterns.CatchTestAssertionResults);
foreach (Match aMatch in aCollection)
{
if (aMatch.Success)
{
TestResults.Passed = false;
TestResults.Assertions = new CatchAssertionResult()
{
TotalAssertions = aMatch.Groups["totalcases"].ToString(),
Passed = aMatch.Groups["passed"].ToString(),
Failed = aMatch.Groups["failed"].ToString()
};
}
}
return TestResults;
}
}
}