2019-12-26 23:01:54 -05:00
|
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2018-09-25 10:11:35 -04:00
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Gauntlet
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Simple node that implements the ITestNode interface and provides some convenience functions for
|
|
|
|
|
|
/// inherited tests to use
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract class BaseTest : ITestNode
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Override this to set the max running time for this test
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract float MaxDuration { get; protected set; }
|
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// What the test result should be treated as if we reach max duration.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual EMaxDurationReachedResult MaxDurationReachedResult { get; set; }
|
|
|
|
|
|
|
2018-09-25 10:11:35 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Override this to set the priority of this test
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual TestPriority Priority { get { return TestPriority.Normal; } }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return the name of this test
|
|
|
|
|
|
/// </summary>
|
2023-01-31 14:46:39 -05:00
|
|
|
|
public abstract string Name { get; }
|
2018-09-25 10:11:35 -04:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns true if the test has encountered warnings. Test is expected to list any warnings it considers appropriate in the summary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual bool HasWarnings { get; protected set; }
|
|
|
|
|
|
|
2020-12-04 17:30:52 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns reason for the test cancellation
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual string CancellationReason { get; protected set; }
|
|
|
|
|
|
|
2018-11-14 19:05:13 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns true if the test was cancelled
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual bool WasCancelled { get; protected set; }
|
|
|
|
|
|
|
2018-09-25 10:11:35 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Internal status state
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private TestStatus InnerStatus;
|
|
|
|
|
|
|
2020-11-24 11:10:24 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return true if the warnings and errors needs to log after summary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual bool LogWarningsAndErrorsAfterSummary { get; protected set; } = true;
|
|
|
|
|
|
|
2018-09-25 10:11:35 -04:00
|
|
|
|
/// <summary>
|
2023-01-31 14:46:39 -05:00
|
|
|
|
/// Default BaseTest Constructor
|
2018-09-25 10:11:35 -04:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public BaseTest()
|
|
|
|
|
|
{
|
2023-01-31 14:46:39 -05:00
|
|
|
|
SetTestStatus(TestStatus.NotStarted);
|
2018-09-25 10:11:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// OVerride this to return the result of the test
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public abstract TestResult GetTestResult();
|
|
|
|
|
|
|
2021-06-23 17:51:32 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set the test result value of the test.
|
|
|
|
|
|
/// </summary>
|
2023-01-31 14:46:39 -05:00
|
|
|
|
/// <param name="InTestResult">New result that the Test should have.</param>
|
|
|
|
|
|
public abstract void SetTestResult(TestResult InTestResult);
|
2021-06-23 17:51:32 -04:00
|
|
|
|
|
2022-03-18 18:53:33 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Add a new test event to be rolled up into the summary at the end of this test.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void AddTestEvent(UnrealTestEvent InEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-09-25 10:11:35 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Summarize the result of the test
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public virtual string GetTestSummary()
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("{0}: {1}", Name, GetTestResult());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-02 00:10:12 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return list of warnings. Empty by default
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public virtual IEnumerable<string> GetWarnings()
|
|
|
|
|
|
{
|
2023-01-31 14:46:39 -05:00
|
|
|
|
return System.Array.Empty<string>();
|
2019-05-02 00:10:12 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return list of errors. Empty by default
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public virtual IEnumerable<string> GetErrors()
|
|
|
|
|
|
{
|
2023-01-31 14:46:39 -05:00
|
|
|
|
return System.Array.Empty<string>();
|
2019-05-02 00:10:12 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-11 02:54:50 -04:00
|
|
|
|
public virtual string GetRunLocalCommand(string LaunchingBuildCommand)
|
|
|
|
|
|
{
|
|
|
|
|
|
string CommandToRunLocally =
|
|
|
|
|
|
string.Format("RunUAT {0} -Test={1} ", LaunchingBuildCommand, GetType());
|
|
|
|
|
|
return CommandToRunLocally;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-31 14:46:39 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Updates the test status to the passed in value
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="InStatus"></param>
|
|
|
|
|
|
protected void SetTestStatus(TestStatus InStatus)
|
|
|
|
|
|
{
|
|
|
|
|
|
InnerStatus = InStatus;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-09-25 10:11:35 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Mark the test as started
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
protected void MarkTestStarted()
|
|
|
|
|
|
{
|
2023-01-31 14:46:39 -05:00
|
|
|
|
SetTestStatus(TestStatus.InProgress);
|
2021-08-12 18:53:24 -04:00
|
|
|
|
SetTestResult(TestResult.Invalid);
|
2018-09-25 10:11:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Mark the test as complete
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
protected void MarkTestComplete()
|
|
|
|
|
|
{
|
2023-01-31 14:46:39 -05:00
|
|
|
|
SetTestStatus(TestStatus.Complete);
|
2018-09-25 10:11:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Return our internal status
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public TestStatus GetTestStatus()
|
|
|
|
|
|
{
|
|
|
|
|
|
return InnerStatus;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual bool IsReadyToStart()
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called to request the test launch. Should call MarkTestComplete
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public abstract bool StartTest(int Pass, int NumPasses);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called to request the test is shutdown
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public abstract void CleanupTest();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called if TestResult returns WantRetry. Can be overridden for something
|
|
|
|
|
|
/// more elegant than a hard shutdown/launch
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public virtual bool RestartTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
CleanupTest();
|
2023-01-31 14:46:39 -05:00
|
|
|
|
return StartTest(0, 1);
|
2018-09-25 10:11:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gives the test a chance to perform logic. Should call MarkComplete() when it detects a
|
|
|
|
|
|
/// success or error state
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public virtual void TickTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-04 17:30:52 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets Cancellation Reason.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="InReason"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public virtual void SetCancellationReason(string InReason)
|
|
|
|
|
|
{
|
|
|
|
|
|
CancellationReason = InReason;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-09-25 10:11:35 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called after the test is completed and shutdown
|
|
|
|
|
|
/// </summary>
|
2021-06-10 13:13:24 -04:00
|
|
|
|
/// <param name="InReason"></param>
|
2018-09-25 10:11:35 -04:00
|
|
|
|
/// <returns></returns>
|
2021-06-10 13:13:24 -04:00
|
|
|
|
public virtual void StopTest(StopReason InReason)
|
2018-09-25 10:11:35 -04:00
|
|
|
|
{
|
2021-06-10 13:13:24 -04:00
|
|
|
|
WasCancelled = InReason != StopReason.Completed;
|
2018-09-25 10:11:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Helper to set context
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="InContext"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public virtual void SetContext(ITestContext InContext)
|
|
|
|
|
|
{
|
2020-04-07 00:50:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Output all defined commandline information for this test to the gauntlet window and exit test early.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void DisplayCommandlineHelp()
|
2023-01-31 14:46:39 -05:00
|
|
|
|
{
|
2020-04-07 00:50:43 -04:00
|
|
|
|
}
|
2018-09-25 10:11:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|