// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using UnrealBuildTool; using Gauntlet; using AutomationTool; using System.Reflection; using UnrealBuildBase; namespace EditorTest { /// /// Default set of options that are available for all "EditorTest" derived notes to configure as /// appropriate. Configurable options are public, external command-line driven options should /// be protected/private and set via AutoParam's /// public class EditorTestConfig : UnrealTestConfiguration, IAutoParamNotifiable { // Global options set via the command line /// /// Name of the EngineTest test to run /// [AutoParam("")] protected string TestName { get; set; } // Global options set via the command line [AutoParam(false)] protected bool Report { get; set; } /// /// Validate external arguments /// /// /// public void ParametersWereApplied(string[] Params) { if (string.IsNullOrEmpty(TestName)) { throw new Exception("No testname was specified. Use -testname="); } } /// /// Applies the selected options to the provided app config /// /// /// /// public override void ApplyToConfig(UnrealAppConfig AppConfig, UnrealSessionRole ConfigRole, IEnumerable OtherRoles) { base.ApplyToConfig(AppConfig, ConfigRole, OtherRoles); if (AppConfig.ProcessType.IsEditor()) { AppConfig.CommandLine += string.Format(" -ExecCmds=\"Automation RunTests Project.Functional Tests.{0}\"", TestName); if (Report) { AppConfig.CommandLine += "-DeveloperReportOutputPath=\"\\rdu-automation-01\\reports\\\" -DeveloperReportUrl=\"http://automation.epicgames.net/reports/\""; } } } } /// /// Base class for common editor test functionality /// public class EditorTestNode : UnrealTestNode { public EditorTestNode(UnrealTestContext InContext) : base(InContext) { } /// /// Returns the configuration for this test /// /// public override EditorTestConfig GetConfiguration() { var Config = base.GetConfiguration(); // create an editor role var EditorRole = Config.RequireRole(UnrealTargetRole.Editor); return Config; } } public class RunEditorTests : Gauntlet.RunUnreal { public override ExitCode Execute() { // Cheat - if we can base everything off a single note, don't require users to specify it by appending it // to our global argument list List ExpandedParams = new List(this.Params); ExpandedParams.Add("test=EditorTestNode"); // save off these params Globals.Params = new Gauntlet.Params(ExpandedParams.ToArray()); // create test options and apply any params UnrealTestOptions ContextOptions = new UnrealTestOptions(); AutoParam.ApplyParamsAndDefaults(ContextOptions, Globals.Params.AllArguments); // These are fixed for this prohect ContextOptions.Project = "EngineTest"; ContextOptions.Namespaces = "EditorTest"; ContextOptions.Build = "Editor"; ContextOptions.UsesSharedBuildType = true; return RunTests(ContextOptions); } } }