/// <summary> /// Create the list of tests specified by the context. /// </summary> /// <param name="Context"></param> /// <returns></returns> IEnumerable <ITestNode> CreateTestList(UnrealTestContext Context, Params DefaultParams, ArgumentWithParams PlatformParams = null) { List <ITestNode> NodeList = new List <ITestNode>(); IEnumerable <string> Namespaces = Context.Options.Namespaces.Split(',').Select(S => S.Trim()); List <string> BuildIssues = new List <string>(); UnrealTargetPlatform UnrealPlatform = UnrealTargetPlatform.Unknown; if (!Enum.TryParse(PlatformParams.Argument, true, out UnrealPlatform)) { throw new AutomationException("Could not convert platform {0} to a valid UnrealTargetPlatform", PlatformParams.Argument); } //List<string> Platforms = Globals.Params.ParseValue("platform") // Create an instance of each test and add it to the executor foreach (var Test in Context.Options.TestList) { // create a copy of the context for this test UnrealTestContext TestContext = (UnrealTestContext)Context.Clone(); // if test specifies platforms, filter for this context if (Test.Platforms.Count() > 0 && Test.Platforms.Where(Plat => Plat.Argument == PlatformParams.Argument).Count() == 0) { continue; } if (Blacklist.Instance.IsTestBlacklisted(Test.TestName, UnrealPlatform, TestContext.BuildInfo.Branch)) { Gauntlet.Log.Info("Test {0} is currently blacklisted on {1} in branch {2}", Test.TestName, UnrealPlatform, TestContext.BuildInfo.Branch); continue; } // combine global and test-specific params Params CombinedParams = new Params(DefaultParams.AllArguments.Concat(Test.TestParams.AllArguments).ToArray()); // parse any target constraints List <string> PerfSpecArgs = CombinedParams.ParseValues("PerfSpec", false); string PerfSpecArg = PerfSpecArgs.Count > 0 ? PerfSpecArgs.Last() : "Unspecified"; EPerfSpec PerfSpec; if (!Enum.TryParse <EPerfSpec>(PerfSpecArg, true, out PerfSpec)) { throw new AutomationException("Unable to convert perfspec '{0}' into an EPerfSpec", PerfSpec); } TestContext.Constraint = new UnrealTargetConstraint(UnrealPlatform, PerfSpec); TestContext.TestParams = CombinedParams; // This will throw if the test cannot be created ITestNode NewTest = Utils.TestConstructor.ConstructTest <ITestNode, UnrealTestContext>(Test.TestName, TestContext, Namespaces); NodeList.Add(NewTest); } return(NodeList); }
/// <summary> /// Called after command line params are applied. Perform any checks / fixup /// </summary> /// <param name="InParams"></param> public virtual void ParametersWereApplied(string[] InParams) { // save params this.Params = new Params(InParams); if (string.IsNullOrEmpty(TempDir)) { TempDir = Globals.TempDir; } else { Globals.TempDir = TempDir; } if (string.IsNullOrEmpty(LogDir)) { LogDir = Globals.LogDir; } else { Globals.LogDir = LogDir; } if (string.IsNullOrEmpty(Sandbox)) { Sandbox = Project; } // parse platforms. These will be in the format of Win64(param1,param2='foo,bar') etc // check for old-style -platform=Win64(params) List <string> PlatformArgStrings = Params.ParseValues("Platform="); // check for convenience flags of -Win64(params) (TODO - need to think about this..) /*foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) * { * IEnumerable<string> RawPlatformArgs = InParams.Where(P => P.ToLower().StartsWith(Plat.ToString().ToLower())); * * PlatformArgStrings.AddRange(RawPlatformArgs); * }*/ // now turn the Plat(param1,param2) etc into an argument/parm pair PlatformList = PlatformArgStrings.SelectMany(P => ArgumentWithParams.CreateFromString(P)).ToList(); List <string> TestArgStrings = Params.ParseValues("test="); // clear all tests incase this is called multiple times TestList.Clear(); if (TestArgStrings.Count == 0) { TestArgStrings = Params.ParseValues("tests="); } foreach (string TestArg in TestArgStrings) { foreach (ArgumentWithParams TestWithParms in ArgumentWithParams.CreateFromString(TestArg)) { TestRequest Test = new TestRequest() { TestName = TestWithParms.Argument, TestParams = new Params(TestWithParms.AllArguments) }; // parse any specified platforms foreach (string PlatformArg in Test.TestParams.ParseValues("Platform=")) { List <ArgumentWithParams> PlatParams = ArgumentWithParams.CreateFromString(PlatformArg); Test.Platforms.AddRange(PlatParams); // register platform in test options PlatParams.ForEach(TestPlat => { if (PlatformList.Where(Plat => Plat.Argument == TestPlat.Argument).Count() == 0) { PlatformList.Add(TestPlat); } }); } TestList.Add(Test); } } if (PlatformList.Count == 0) { // Default to local platform PlatformList.Add(new ArgumentWithParams(BuildHostPlatform.Current.Platform.ToString(), new string[0])); } // do we have any tests? Need to check the global test list bool HaveTests = TestList.Count > 0 || PlatformList.Where(Plat => Plat.ParseValues("test").Count() > 0).Count() > 0; // turn -device=BobsKit,BobsKit(PS4) into a device list List <string> DeviceArgStrings = Params.ParseValues("device="); if (DeviceArgStrings.Count == 0) { DeviceArgStrings = Params.ParseValues("devices="); } DeviceList = DeviceArgStrings.SelectMany(D => ArgumentWithParams.CreateFromString(D)).ToList(); if (DeviceList.Count == 0) { // Add the default test DeviceList.Add(new ArgumentWithParams("default", new string[0])); } // remote all -test and -platform arguments from our params. Nothing else should be looking at these now... string[] CleanArgs = Params.AllArguments .Where(Arg => !Arg.StartsWith("test=", StringComparison.OrdinalIgnoreCase) && !Arg.StartsWith("platform=", StringComparison.OrdinalIgnoreCase) && !Arg.StartsWith("device=", StringComparison.OrdinalIgnoreCase)) .ToArray(); Params = new Params(CleanArgs); }