/// <summary> /// Cleanup all resources /// </summary> /// <param name="Node"></param> /// <returns></returns> public override void CleanupTest() { if (TestInstance != null) { TestInstance.Dispose(); TestInstance = null; } if (UnrealApp != null) { UnrealApp.Dispose(); UnrealApp = null; } }
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); }