// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.IO; using System.Linq; using EpicGames.Core; using UnrealBuildTool; using UnrealBuildBase; using AutomationTool; namespace Gauntlet.SelfTest { /// /// Base class for Unreal tests. Mostly provides Build / Environment info /// abstract class TestUnrealBase : BaseTestNode { /// /// Name of the project we're testing /// public string ProjectName { get; protected set; } /// /// Name of the project we're testing /// public FileReference ProjectFile { get; protected set; } /// /// Path to Unreal /// public DirectoryReference UnrealPath { get; protected set; } /// /// True if this project uses the Game/NoEditor shared build type instead of separate client/server ones /// public bool UsesSharedBuildType { get; protected set; } /// /// Name of devkit to use for tests /// public string DevkitName { get; protected set; } /// /// Path of the build to test against /// public string BuildPath { get; protected set; } /// /// Client platforms we support /// public UnrealTargetPlatform[] SupportedClientPlatforms { get; protected set; } /// /// Server platforms we support /// public UnrealTargetPlatform[] SupportedServerPlatforms { get; protected set; } /// /// Configurations we support /// public UnrealTargetConfiguration[] SupportedConfigurations { get; protected set; } /// /// Target Configuration /// public UnrealTargetConfiguration Configuration { get; protected set; } public TestUnrealBase() { ProjectName = Gauntlet.Globals.Params.ParseValue("Project", "EngineTest"); string ConfigurationString = Gauntlet.Globals.Params.ParseValue("Configuration", "Development"); BuildPath = Gauntlet.Globals.Params.ParseValue("Build", null); DevkitName = Gauntlet.Globals.Params.ParseValue("Device", "Default"); UnrealPath = Unreal.RootDirectory; UsesSharedBuildType = false; if (File.Exists(ProjectName)) { ProjectFile = new FileReference(ProjectName); ProjectName = ProjectFile.GetFileNameWithoutExtension(); } else { if (!string.IsNullOrEmpty(ProjectName)) { ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectName); if (ProjectFile == null) { throw new AutomationException("Could not find project file for {0}", ProjectName); } ProjectName = ProjectFile.GetFileNameWithoutExtension(); } } if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64) { IEnumerable SupportedDevices = Gauntlet.Utils.InterfaceHelpers.FindImplementations().Select(D => D.GetPlatform() ?? UnrealTargetPlatform.Win64); SupportedClientPlatforms = SupportedDevices.Append(UnrealTargetPlatform.Win64).Distinct().ToArray(); SupportedServerPlatforms = new[] { UnrealTargetPlatform.Win64, UnrealTargetPlatform.Linux }; } else { SupportedClientPlatforms = new[] { UnrealTargetPlatform.Mac }; SupportedServerPlatforms = new[] { UnrealTargetPlatform.Mac }; } SupportedConfigurations = new[] { UnrealTargetConfiguration.Development, UnrealTargetConfiguration.Test }; object RequestedConfiguration; if (!Enum.TryParse(typeof(UnrealTargetConfiguration), ConfigurationString, true, out RequestedConfiguration)) { string AllKeys = string.Join(", ", SupportedConfigurations); throw new AutomationException(string.Format("Unknown Configuration '{0}', it must be one of the values: {1}.", ConfigurationString, AllKeys)); } Configuration = (UnrealTargetConfiguration)RequestedConfiguration; } } }