/// <summary> /// Returns a priority value for this test /// </summary> /// <returns></returns> protected TestPriority GetPriority() { IEnumerable <UnrealTargetPlatform> DesktopPlatforms = UnrealBuildTool.Utils.GetPlatformsInClass(UnrealPlatformClass.Desktop); UnrealTestRoleContext ClientContext = Context.GetRoleContext(UnrealTargetRole.Client); // because these need deployed we want them in flight asap if (ClientContext.Platform == UnrealTargetPlatform.PS4 || ClientContext.Platform == UnrealTargetPlatform.XboxOne) { return(TestPriority.High); } return(TestPriority.Normal); }
/// <summary> /// Execute all tests according to the provided context /// </summary> /// <param name="Context"></param> /// <returns></returns> public ExitCode RunTests(UnrealTestOptions ContextOptions) { if (ContextOptions.Verbose) { Gauntlet.Log.Level = Gauntlet.LogLevel.Verbose; } if (ContextOptions.VeryVerbose) { Gauntlet.Log.Level = Gauntlet.LogLevel.VeryVerbose; } if (ParseParam("log")) { if (!Directory.Exists(ContextOptions.LogDir)) { Directory.CreateDirectory(ContextOptions.LogDir); } // include test names and timestamp in log filename as multiple (parallel or sequential) Gauntlet tests may be outputting to same directory string LogPath = Path.Combine(ContextOptions.LogDir, string.Format("GauntletLog{0}-{1}.txt", ContextOptions.TestList.Aggregate(new StringBuilder(), (SB, T) => SB.AppendFormat("-{0}", T.ToString())).ToString(), DateTime.Now.ToString(@"yyyy.MM.dd.HH.mm.ss"))); Gauntlet.Log.Verbose("Writing Gauntlet log to {0}", LogPath); Gauntlet.Log.SaveToFile(LogPath); } // prune our temp folder Utils.SystemHelpers.CleanupMarkedDirectories(ContextOptions.TempDir, 7); if (string.IsNullOrEmpty(ContextOptions.Build)) { throw new AutomationException("No builds specified. Use -builds=p:\\path\\to\\build"); } if (typeof(UnrealBuildSource).IsAssignableFrom(ContextOptions.BuildSourceType) == false) { throw new AutomationException("Provided BuildSource type does not inherit from UnrealBuildSource"); } // make -test=none implicit if no test is supplied if (ContextOptions.TestList.Count == 0) { Gauntlet.Log.Info("No test specified, creating default test node"); ContextOptions.TestList.Add(TestRequest.CreateRequest("DefaultTest")); } bool EditorForAllRoles = Globals.Params.ParseParam("editor") || string.Equals(Globals.Params.ParseValue("build", ""), "editor", StringComparison.OrdinalIgnoreCase); if (EditorForAllRoles) { Gauntlet.Log.Verbose("Will use Editor for all roles"); } Dictionary <UnrealTargetRole, UnrealTestRoleContext> RoleContexts = new Dictionary <UnrealTargetRole, UnrealTestRoleContext>(); // Default platform to the current os UnrealTargetPlatform DefaultPlatform = BuildHostPlatform.Current.Platform; UnrealTargetConfiguration DefaultConfiguration = UnrealTargetConfiguration.Development; // todo, pass this in as a BuildSource and remove the COntextOption params specific to finding builds UnrealBuildSource BuildInfo = (UnrealBuildSource)Activator.CreateInstance(ContextOptions.BuildSourceType, new object[] { ContextOptions.Project, ContextOptions.UsesSharedBuildType, Environment.CurrentDirectory, ContextOptions.Build, ContextOptions.SearchPaths }); // Setup accounts SetupAccounts(); List <ITestNode> AllTestNodes = new List <ITestNode>(); bool InitializedDevices = false; HashSet <UnrealTargetPlatform> UsedPlatforms = new HashSet <UnrealTargetPlatform>(); // for all platforms we want to test... foreach (ArgumentWithParams PlatformWithParams in ContextOptions.PlatformList) { string PlatformString = PlatformWithParams.Argument; // combine global and platform-specific params Params CombinedParams = new Params(ContextOptions.Params.AllArguments.Concat(PlatformWithParams.AllArguments).ToArray()); UnrealTargetPlatform PlatformType; if (!Enum.TryParse <UnrealTargetPlatform>(PlatformString, true, out PlatformType)) { throw new AutomationException("Unable to convert platform '{0}' into an UnrealTargetPlatform", PlatformString); } if (!InitializedDevices) { // Setup the devices and assign them to the executor SetupDevices(PlatformType, ContextOptions); InitializedDevices = true; } // Create a context for each process type to operate as foreach (UnrealTargetRole Type in Enum.GetValues(typeof(UnrealTargetRole))) { UnrealTestRoleContext Role = new UnrealTestRoleContext(); // Default to these Role.Type = Type; Role.Platform = DefaultPlatform; Role.Configuration = DefaultConfiguration; // globally, what was requested (e.g -platform=PS4 -configuration=Shipping) UnrealTargetPlatform RequestedPlatform = PlatformType; UnrealTargetConfiguration RequestedConfiguration = ContextOptions.Configuration; // look for FooConfiguration, FooPlatform overrides. // e.g. ServerConfiguration, ServerPlatform string PlatformRoleString = Globals.Params.ParseValue(Type.ToString() + "Platform", null); string ConfigString = Globals.Params.ParseValue(Type.ToString() + "Configuration", null); if (string.IsNullOrEmpty(PlatformRoleString) == false) { RequestedPlatform = (UnrealTargetPlatform)Enum.Parse(typeof(UnrealTargetPlatform), PlatformRoleString, true); } if (string.IsNullOrEmpty(ConfigString) == false) { RequestedConfiguration = (UnrealTargetConfiguration)Enum.Parse(typeof(UnrealTargetConfiguration), ConfigString, true); } // look for -clientargs= and -editorclient etc Role.ExtraArgs = Globals.Params.ParseValue(Type.ToString() + "Args", ""); bool UsesEditor = EditorForAllRoles || Globals.Params.ParseParam("Editor" + Type.ToString()); if (UsesEditor) { Gauntlet.Log.Verbose("Will use Editor for role {0}", Type); } Role.Skip = Globals.Params.ParseParam("Skip" + Type.ToString()); if (Role.Skip) { Gauntlet.Log.Verbose("Will use NullPlatform to skip role {0}", Type); } // TODO - the below is a bit rigid, but maybe that's good enough since the "actually use the editor.." option // is specific to clients and servers // client can override platform and config if (Type.IsClient()) { Role.Platform = RequestedPlatform; Role.Configuration = RequestedConfiguration; if (UsesEditor) { Role.Type = UnrealTargetRole.EditorGame; Role.Platform = DefaultPlatform; Role.Configuration = UnrealTargetConfiguration.Development; } } else if (Type.IsServer()) { // server can only override config Role.Configuration = RequestedConfiguration; if (UsesEditor) { Role.Type = UnrealTargetRole.EditorServer; Role.Platform = DefaultPlatform; Role.Configuration = UnrealTargetConfiguration.Development; } } Gauntlet.Log.Verbose("Mapped Role {0} to RoleContext {1}", Type, Role); RoleContexts[Type] = Role; UsedPlatforms.Add(Role.Platform); } UnrealTestContext Context = new UnrealTestContext(BuildInfo, RoleContexts, ContextOptions); IEnumerable <ITestNode> TestNodes = CreateTestList(Context, CombinedParams, PlatformWithParams); AllTestNodes.AddRange(TestNodes); } bool AllTestsPassed = ExecuteTests(ContextOptions, AllTestNodes); // dispose now, not during shutdown gc, because this runs commands... DevicePool.Instance.Dispose(); DoCleanup(UsedPlatforms); return(AllTestsPassed ? ExitCode.Success : ExitCode.Error_TestFailure); }
protected bool PrepareUnrealApp() { // Get our configuration TConfigClass Config = GetConfiguration(); if (Config == null) { throw new AutomationException("Test {0} returned null config!", this); } if (UnrealApp != null) { throw new AutomationException("Node already has an UnrealApp, was PrepareUnrealSession called twice?"); } // pass through any arguments such as -TestNameArg or -TestNameArg=Value var TestName = this.GetType().Name; var ShortName = TestName.Replace("Test", ""); var PassThroughArgs = Context.TestParams.AllArguments .Where(A => A.StartsWith(TestName, System.StringComparison.OrdinalIgnoreCase) || A.StartsWith(ShortName, System.StringComparison.OrdinalIgnoreCase)) .Select(A => { A = "-" + A; var EqIndex = A.IndexOf("="); // no =? Just a -switch then if (EqIndex == -1) { return(A); } var Cmd = A.Substring(0, EqIndex + 1); var Args = A.Substring(EqIndex + 1); // if no space in the args, just leave it if (Args.IndexOf(" ") == -1) { return(A); } return(string.Format("{0}\"{1}\"", Cmd, Args)); }); List <UnrealSessionRole> SessionRoles = new List <UnrealSessionRole>(); // Go through each type of role that was required and create a session role foreach (var TypesToRoles in Config.RequiredRoles) { // get the actual context of what this role means. UnrealTestRoleContext RoleContext = Context.GetRoleContext(TypesToRoles.Key); foreach (UnrealTestRole TestRole in TypesToRoles.Value) { // important, use the type from the ContextRolke because Server may have been mapped to EditorServer etc UnrealTargetPlatform SessionPlatform = TestRole.PlatformOverride != UnrealTargetPlatform.Unknown ? TestRole.PlatformOverride : RoleContext.Platform; UnrealSessionRole SessionRole = new UnrealSessionRole(RoleContext.Type, SessionPlatform, RoleContext.Configuration, TestRole.CommandLine); SessionRole.RoleModifier = TestRole.RoleType; SessionRole.Constraint = TestRole.Type == UnrealTargetRole.Client ? Context.Constraint : new UnrealTargetConstraint(SessionPlatform); Log.Verbose("Created SessionRole {0} from RoleContext {1} (RoleType={2})", SessionRole, RoleContext, TypesToRoles.Key); // TODO - this can all / mostly go into UnrealTestConfiguration.ApplyToConfig // Deal with command lines if (string.IsNullOrEmpty(TestRole.ExplicitClientCommandLine) == false) { SessionRole.CommandLine = TestRole.ExplicitClientCommandLine; } else { // start with anything from our context SessionRole.CommandLine = RoleContext.ExtraArgs; // did the test ask for anything? if (string.IsNullOrEmpty(TestRole.CommandLine) == false) { SessionRole.CommandLine += " " + TestRole.CommandLine; } // add controllers if (TestRole.Controllers.Count > 0) { SessionRole.CommandLine += string.Format(" -gauntlet=\"{0}\"", string.Join(",", TestRole.Controllers)); } if (PassThroughArgs.Count() > 0) { SessionRole.CommandLine += " " + string.Join(" ", PassThroughArgs); } // add options SessionRole.Options = Config; } if (RoleContext.Skip) { SessionRole.RoleModifier = ERoleModifier.Null; } SessionRole.FilesToCopy = TestRole.FilesToCopy; SessionRoles.Add(SessionRole); } } UnrealApp = new UnrealSession(Context.BuildInfo, SessionRoles) { Sandbox = Context.Options.Sandbox }; return(true); }