/// <summary> /// Returns information about how to configure our Unreal processes. For the most part the majority /// of Unreal tests should only need to override this function /// </summary> /// <returns></returns> public virtual TConfigClass GetConfiguration() { if (CachedConfig == null) { CachedConfig = new TConfigClass(); AutoParam.ApplyParamsAndDefaults(CachedConfig, this.Context.TestParams.AllArguments); } return(CachedConfig); }
/// <summary> /// Main UAT entrance point. Custom games can derive from RunUnrealTests to run custom setup steps or /// directly set params on ContextOptions to remove the need for certain command line params (e.g. /// -project=FooGame /// </summary> /// <returns></returns> public override ExitCode Execute() { Globals.Params = new Gauntlet.Params(this.Params); UnrealTestOptions ContextOptions = new UnrealTestOptions(); AutoParam.ApplyParamsAndDefaults(ContextOptions, Globals.Params.AllArguments); if (string.IsNullOrEmpty(ContextOptions.Project)) { throw new AutomationException("No project specified. Use -project=ShooterGame etc"); } ContextOptions.Namespaces = "Gauntlet.UnrealTest,UE4Game"; ContextOptions.UsesSharedBuildType = true; return(RunTests(ContextOptions)); }
public override ExitCode Execute() { AutoParam.ApplyParamsAndDefaults(this, Environment.GetCommandLineArgs()); if (Verbose) { Gauntlet.Log.Level = Gauntlet.LogLevel.Verbose; } IEnumerable <string> TestList = new string[0]; // If a group was specified... if (Group.Length > 0) { // if a group was specified, find those tests TestList = Utils.TestConstructor.GetTestNamesByGroup <ITestNode>(Group, new[] { "Gauntlet.SelfTest" }); } else if (Tests.Length > 0) { // list of tests? TestList = Tests.Split(',').Select(S => S.Trim()); } else { // Ok, run everything! TestList = Utils.TestConstructor.GetTestNamesByGroup <ITestNode>(null, new[] { "Gauntlet.SelfTest" }); } // Create the list of tests IEnumerable <ITestNode> Nodes = Utils.TestConstructor.ConstructTests <ITestNode, string[]>(TestList, null, new[] { "Gauntlet.SelfTest" }); // Create the test executor var Executor = new TextExecutor(); TestExecutorOptions Options = new TestExecutorOptions(); AutoParam.ApplyParamsAndDefaults(Options, this.Params); bool AllTestsPassed = Executor.ExecuteTests(Options, Nodes); return(AllTestsPassed ? ExitCode.Success : ExitCode.Error_TestFailure); }
public override AutomationTool.ExitCode Execute() { AutoParam.ApplyParamsAndDefaults(this, Environment.GetCommandLineArgs()); Gauntlet.Log.Level = Gauntlet.LogLevel.VeryVerbose; if (string.IsNullOrEmpty(TempDir) == false) { Globals.TempDir = TempDir; } // add devices. We're quick so can ignore constraints DevicePool.Instance.SetLocalOptions(TempDir, false, DeviceURL); DevicePool.Instance.AddDevices(UnrealTargetPlatform.Win64, Devices, false); UnrealTargetPlatform[] SupportedPlatforms = { UnrealTargetPlatform.PS4, UnrealTargetPlatform.Win64 }; foreach (UnrealTargetPlatform Platform in SupportedPlatforms) { DevicePool.Instance.EnumerateDevices(Platform, Device => { try { CleanDevice(Device); } catch (Exception Ex) { Gauntlet.Log.Warning("Exception cleaning device: {0}", Ex); } return(true); }); } DevicePool.Instance.Dispose(); return(AutomationTool.ExitCode.Success); }
/// <summary> /// Call to process all CommandLineOption attributes on an objects members and set them based on the /// provided argument list /// </summary> /// <param name="Obj"></param> /// <param name="Args"></param> protected static void ApplyParamsAndDefaultsInternal(object Obj, string[] Args, bool ApplyDefaults) { // get all field and property members var Fields = Obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); var Properties = Obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); var AllMembers = Fields.Cast <MemberInfo>().Concat(Properties); foreach (var Member in AllMembers) { Type MemberType = null; // Get the type of the member (note - this is not Member.Type!) if (Member is PropertyInfo) { MemberType = ((PropertyInfo)Member).PropertyType; } else if (Member is FieldInfo) { MemberType = ((FieldInfo)Member).FieldType; } // Go through all attributes foreach (object Attrib in Member.GetCustomAttributes(true)) { if (Attrib is AutoParam) { // If this is a struct then we want to recurse if (IsSimple(MemberType) == false) { object Value = null; // Get the reference value if (Member is PropertyInfo) { Value = ((PropertyInfo)Member).GetValue(Obj); } else if (Member is FieldInfo) { Value = ((FieldInfo)Member).GetValue(Obj); } // if null create a new one (e.g. a new instance of a struct); if (Value == null) { try { Value = Activator.CreateInstance(MemberType); } catch { throw new AutomationException("Add a default constructor to the class {0}!", MemberType); } // Set the new object as the refernce if (Member is PropertyInfo) { ((PropertyInfo)Member).SetValue(Obj, Value); } else if (Member is FieldInfo) { ((FieldInfo)Member).SetValue(Obj, Value); } } // Recurse into this struct ApplyParamsAndDefaultsInternal(Value, Args, ApplyDefaults); } else { AutoParam Opt = Attrib as AutoParam; // if the attribute had names provided use them, else use the name of the variable string[] ParamNames = (Opt.OptionNames != null && Opt.OptionNames.Length > 0) ? Opt.OptionNames : new string[] { Member.Name }; // save the default object DefaultValue = Opt.Default; object NewValue = null; if (DefaultValue != null && DefaultValue.GetType() != MemberType) { Log.Warning("AutoParam default value for member {0} is type {1}, not {2}", Member.Name, DefaultValue.GetType(), MemberType); } // Go through all params used to refer to this member foreach (string Name in ParamNames) { // if default is a bool then just check if the switch exists if (MemberType == typeof(bool)) { if (SwitchExists(Name, Args)) { NewValue = true; } } else { // for all other types try to parse out the value NewValue = ParaseAndCoerceParam(Name, MemberType, Args); } // stop as soon as we find something if (NewValue != null) { break; } } // If no value was found, use the default if (NewValue != null || (ApplyDefaults && DefaultValue != null)) { if (NewValue == null) { NewValue = DefaultValue; } if (MemberType.IsEnum) { if (NewValue.GetType() != MemberType) { Log.Warning("Default for member {0} is an enum of an incorrect type!", Member.Name); } } else { // Force a conversion - need to do this even for default values incase someone specified a double for a float NewValue = Convert.ChangeType(NewValue, MemberType); } // Set the value on the member if (Member is PropertyInfo) { ((PropertyInfo)Member).SetValue(Obj, NewValue); } else if (Member is FieldInfo) { ((FieldInfo)Member).SetValue(Obj, NewValue); } } } } } } IAutoParamNotifiable ParamNotifable = Obj as IAutoParamNotifiable; if (ParamNotifable != null) { ParamNotifable.ParametersWereApplied(Args); } }
public UnrealOptions() { AutoParam.ApplyDefaults(this); }