예제 #1
0
 /// <summary>
 /// Adds one role of the specified type to this test. With inherited tests this could
 /// return an existing role so care should be added to append commandlines, controllers etc
 /// </summary>
 /// <param name="Role"></param>
 /// <returns></returns>
 public UnrealTestRole RequireRole(UnrealTargetRole InRole)
 {
     return(RequireRoles(InRole, 1).First());
 }
예제 #2
0
 public UnrealTestRole RequireRole(UnrealTargetRole InRole, UnrealTargetPlatform PlatformOverride)
 {
     return(RequireRoles(InRole, PlatformOverride, 1).First());
 }
 public BuildData(string InProjectName, string InFilename, UnrealTargetConfiguration InConfiguration, UnrealTargetPlatform InPlatform, UnrealTargetRole InRole, bool InContentProject = false)
 {
     ProjectName           = InProjectName;
     FileName              = InFilename;
     ExpectedConfiguration = InConfiguration;
     ExpectedPlatform      = InPlatform;
     ExpectedRole          = InRole;
     ContentProject        = InContentProject;
 }
 public UnrealTestRoleContext GetRoleContext(UnrealTargetRole Role)
 {
     return(RoleContext[Role]);
 }
 public static bool IsServer(this UnrealTargetRole Type)
 {
     return(Type == UnrealTargetRole.EditorServer || Type == UnrealTargetRole.Server);
 }
 /// <summary>
 /// Constructor taking limited params
 /// </summary>
 /// <param name="InType"></param>
 /// <param name="InPlatform"></param>
 /// <param name="InConfiguration"></param>
 /// <param name="InOptions"></param>
 public UnrealSessionRole(UnrealTargetRole InType, UnrealTargetPlatform?InPlatform, UnrealTargetConfiguration InConfiguration, IConfigOption <UnrealAppConfig> InOptions)
     : this(InType, InPlatform, InConfiguration, null, InOptions)
 {
 }
예제 #7
0
 public bool CanSupportRole(UnrealTargetRole InRoleType)
 {
     return(InRoleType.UsesEditor());
 }
 public ConfigInfo()
 {
     RoleType      = UnrealTargetRole.Unknown;
     Configuration = UnrealTargetConfiguration.Unknown;
 }
예제 #9
0
 public static bool RunsLocally(this UnrealTargetRole Type)
 {
     return(UsesEditor(Type) || IsServer(Type));
 }
 /// <summary>
 /// Adds 'Count' of the specified roles to this test
 /// </summary>
 /// <param name="Role"></param>
 /// <param name="Count"></param>
 /// <returns></returns>
 public IEnumerable <UnrealTestRole> RequireRoles(UnrealTargetRole InRole, int Count)
 {
     return(RequireRoles(InRole, UnrealTargetPlatform.Unknown, Count));
 }
예제 #11
0
 public static bool IsEditor(this UnrealTargetRole Type)
 {
     return(Type == UnrealTargetRole.Editor);
 }
예제 #12
0
        /// <summary>
        /// Given a platform, a build config, and true/false for client, returns the path to the binary for that config. E.g.
        /// Win64, Shipping, false = Binaries\Win64\FooServer-Win64-Shipping.exe
        /// </summary>
        /// <param name="TargetPlatform"></param>
        /// <param name="BuildConfig"></param>
        /// <param name="IsClient"></param>
        /// <returns></returns>
        virtual public string GetRelativeExecutablePath(UnrealTargetRole TargetType, UnrealTargetPlatform TargetPlatform, UnrealTargetConfiguration TargetConfiguration)
        {
            string ExePath;

            if (TargetType.UsesEditor())
            {
                ExePath = string.Format("Engine/Binaries/{0}/UE4Editor{1}", BuildHostPlatform.Current.Platform, Platform.GetExeExtension(TargetPlatform));
            }
            else
            {
                string BuildType = "";

                if (TargetType == UnrealTargetRole.Client)
                {
                    if (!UsesSharedBuildType)
                    {
                        BuildType = "Client";
                    }
                }
                else if (TargetType == UnrealTargetRole.Server)
                {
                    if (!UsesSharedBuildType)
                    {
                        BuildType = "Server";
                    }
                }

                bool IsRunningDev = Globals.Params.ParseParam("dev");

                // Turn FooGame into Foo
                string ExeBase = ProjectName.Replace("Game", "");

                if (TargetPlatform == UnrealTargetPlatform.Android)
                {
                    // use the archive results for android.
                    //var AndroidSource = new AndroidBuild(ProjectName, GetPlatformPath(TargetType, TargetPlatform), TargetConfiguration);

                    // We always (currently..) need to be able to replace the command line
                    BuildFlags Flags = BuildFlags.CanReplaceCommandLine;
                    if (IsRunningDev)
                    {
                        Flags |= BuildFlags.CanReplaceExecutable;
                    }
                    if (Globals.Params.ParseParam("bulk"))
                    {
                        Flags |= BuildFlags.Bulk;
                    }

                    var Build = GetMatchingBuilds(TargetType, TargetPlatform, TargetConfiguration, Flags).FirstOrDefault();

                    if (Build != null)
                    {
                        AndroidBuild AndroidBuild = Build as AndroidBuild;
                        ExePath = AndroidBuild.SourceApkPath;
                    }
                    else
                    {
                        throw new AutomationException("No suitable build for {0} found at {1}", TargetPlatform, string.Join(",", BuildPaths));
                    }

                    //ExePath = AndroidSource.SourceApkPath;
                }
                else
                {
                    string ExeFileName = string.Format("{0}{1}", ExeBase, BuildType);

                    if (TargetConfiguration != UnrealTargetConfiguration.Development)
                    {
                        ExeFileName += string.Format("-{0}-{1}", TargetPlatform.ToString(), TargetConfiguration.ToString());
                    }

                    ExeFileName += Platform.GetExeExtension(TargetPlatform);

                    string BasePath      = GetPlatformPath(TargetType, TargetPlatform);
                    string ProjectBinary = string.Format("{0}\\Binaries\\{1}\\{2}", ProjectName, TargetPlatform.ToString(), ExeFileName);
                    string StubBinary    = Path.Combine(BasePath, ExeFileName);
                    string DevBinary     = Path.Combine(Environment.CurrentDirectory, ProjectBinary);

                    string NonCodeProjectName   = "UE4Game" + Platform.GetExeExtension(TargetPlatform);
                    string NonCodeProjectBinary = Path.Combine(BasePath, "Engine", "Binaries", TargetPlatform.ToString());
                    NonCodeProjectBinary = Path.Combine(NonCodeProjectBinary, NonCodeProjectName);

                    // check the project binaries folder
                    if (File.Exists(Path.Combine(BasePath, ProjectBinary)))
                    {
                        ExePath = ProjectBinary;
                    }
                    else if (File.Exists(StubBinary))
                    {
                        ExePath = Path.Combine(BasePath, ExeFileName);
                    }
                    else if (IsRunningDev && File.Exists(DevBinary))
                    {
                        ExePath = DevBinary;
                    }
                    else if (File.Exists(NonCodeProjectBinary))
                    {
                        ExePath = NonCodeProjectBinary;
                    }
                    else
                    {
                        List <string> CheckedFiles = new List <String>()
                        {
                            Path.Combine(BasePath, ProjectBinary), StubBinary, NonCodeProjectBinary
                        };
                        if (IsRunningDev)
                        {
                            CheckedFiles.Add(DevBinary);
                        }

                        throw new AutomationException("Executable not found, upstream compile job may have failed.  Could not find executable {0} within {1}, binaries checked: {2}", ExeFileName, BasePath, String.Join(" - ", CheckedFiles));
                    }
                }
            }

            return(Utils.SystemHelpers.CorrectDirectorySeparators(ExePath));
        }
예제 #13
0
        public static IEnumerable <AndroidBuild> CreateFromPath(string InProjectName, string InPath)
        {
            string BuildPath = InPath;

            List <AndroidBuild> DiscoveredBuilds = new List <AndroidBuild>();

            DirectoryInfo Di = new DirectoryInfo(BuildPath);


            // find all install batchfiles
            FileInfo[] InstallFiles = Di.GetFiles("Install_*");

            foreach (FileInfo Fi in InstallFiles)
            {
                bool PackageIs32Bit = Fi.FullName.Contains("armv7");

                UnrealTargetConfiguration UnrealConfig = UnrealHelpers.GetConfigurationFromExecutableName(InProjectName, Fi.FullName);
                UnrealTargetRole          UnrealRole   = UnrealHelpers.GetRoleFromExecutableName(InProjectName, Fi.FullName);

                if (UnrealConfig == UnrealTargetConfiguration.Unknown)
                {
                    Log.Info("Skipping unrecognized build {0}", Fi.FullName);
                    continue;
                }

                bool TestInstall  = Fi.Name.EndsWith("_TEST.bat", StringComparison.OrdinalIgnoreCase);
                bool PatchInstall = Fi.Name.EndsWith("_Patch.bat", StringComparison.OrdinalIgnoreCase);

                // filter out non-matching or test installation batch files
                // test installation scripts are intended to be manually invoked
                if (TestInstall || PatchInstall)
                {
                    if (TestInstall || PatchInstall)
                    {
                        Log.Verbose("Ignoring {0} installation batch file {1}", TestInstall ? "test" : "patch", Fi.Name);
                    }

                    continue;
                }

                Log.Verbose("Pulling install data from {0}", Fi.FullName);

                string AbsPath = Fi.Directory.FullName;

                // read contents and replace linefeeds (regex doesn't stop on them :((
                string BatContents = File.ReadAllText(Fi.FullName).Replace(Environment.NewLine, "\n");

                // Replace .bat with .apk and strip up to and including the first _, that is then our APK name
                var SourceApkMatch = Regex.Match(BatContents, @" install\s+(.+\.apk)");
                if (SourceApkMatch.Groups.Count <= 0)
                {
                    Log.Warning("Could not parse install command from {0}", Fi.FullName);
                    continue;
                }
                string SourceApkPath = Path.Combine(AbsPath, SourceApkMatch.Groups[1].ToString());

                // save com.companyname.product
                string AndroidPackageName = Regex.Match(BatContents, @"uninstall\s+(com\..+)").Groups[1].ToString();

                // pull all OBBs (probably just one..)
                var OBBMatches = Regex.Matches(BatContents, @"push\s+(.+?)\s+(.+)");

                // save them as a dict of full paths as keys and dest paths as values
                Dictionary <string, string> FilesToInstall = OBBMatches.Cast <Match>().ToDictionary(M => Path.Combine(AbsPath, M.Groups[1].ToString()), M => M.Groups[2].ToString());

                if (string.IsNullOrEmpty(SourceApkPath))
                {
                    Log.Warning("No APK found for build at {0}", Fi.FullName);
                    continue;
                }

                if (!File.Exists(SourceApkPath))
                {
                    Log.Warning("Resolved APK name but it doesn't exist {0}", SourceApkPath);
                    continue;
                }

                if (string.IsNullOrEmpty(AndroidPackageName))
                {
                    Log.Warning("No product name found for build at {0}", Fi.FullName);
                    continue;
                }

                // Android builds are always packaged, and we can always replace the command line
                BuildFlags Flags = BuildFlags.Packaged | BuildFlags.CanReplaceCommandLine;

                // if there's data then the pak files are in an obb and we can sub in a new exe
                if (FilesToInstall.Count() > 0)
                {
                    Flags |= BuildFlags.CanReplaceExecutable;
                }
                if (AbsPath.Contains("Bulk"))
                {
                    Flags |= BuildFlags.Bulk;
                }
                else
                {
                    Flags |= BuildFlags.NotBulk;
                }

                AndroidBuild NewBuild = new AndroidBuild(UnrealConfig, AndroidPackageName, SourceApkPath, FilesToInstall, Flags, PackageIs32Bit);

                DiscoveredBuilds.Add(NewBuild);

                Log.Verbose("Found {0} {1} build at {2}", UnrealConfig, ((Flags & BuildFlags.Bulk) == BuildFlags.Bulk) ? "(bulk)" : "(not bulk)", AbsPath);
            }

            // If we have both 32 and 64-bit builds, prefer 64-bit
            if (DiscoveredBuilds.Where(B => B.Is32Bit == false).Any())
            {
                DiscoveredBuilds = DiscoveredBuilds.Where(B => !B.Is32Bit).ToList();
            }

            return(DiscoveredBuilds);
        }
예제 #14
0
 /// <summary>
 /// Adds 'Count' of the specified roles to this test
 /// </summary>
 /// <param name="Role"></param>
 /// <param name="Count"></param>
 /// <returns></returns>
 public IEnumerable <UnrealTestRole> RequireRoles(UnrealTargetRole InRole, int Count)
 {
     return(RequireRoles(InRole, null, Count));
 }
예제 #15
0
 public virtual bool CanSupportRole(UnrealTargetRole InRoleType)
 {
     return(InRoleType == Role);
 }
        static public string GetExecutableName(string ProjectName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Config, UnrealTargetRole Role, string Extension)
        {
            string ExeName = ProjectName;

            if (Role == UnrealTargetRole.Server)
            {
                ExeName = Regex.Replace(ExeName, "Game", "Server", RegexOptions.IgnoreCase);
            }
            else if (Role == UnrealTargetRole.Client)
            {
                ExeName = Regex.Replace(ExeName, "Game", "Client", RegexOptions.IgnoreCase);
            }

            if (Config != UnrealTargetConfiguration.Development)
            {
                ExeName += string.Format("-{0}-{1}", Platform, Config);
            }

            // todo , how to find this?
            if (Platform == UnrealTargetPlatform.Android)
            {
                ExeName += "-arm64";
            }

            // not all platforms use an extension
            if (!string.IsNullOrEmpty(Extension))
            {
                if (Extension.StartsWith(".") == false)
                {
                    ExeName += ".";
                }

                ExeName += Extension;
            }

            return(ExeName);
        }
예제 #17
0
 public StagedBuild(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfig, UnrealTargetRole InRole, string InBuildPath, string InExecutablePath)
 {
     Platform       = InPlatform;
     Configuration  = InConfig;
     Role           = InRole;
     BuildPath      = InBuildPath;
     ExecutablePath = InExecutablePath;
     Flags          = BuildFlags.CanReplaceCommandLine | BuildFlags.CanReplaceExecutable | BuildFlags.Loose;
 }
 public static bool UsesEditor(this UnrealTargetRole Type)
 {
     return(Type == UnrealTargetRole.Editor || Type == UnrealTargetRole.EditorGame || Type == UnrealTargetRole.EditorServer);
 }
예제 #19
0
        public static IEnumerable <T> CreateFromPath <T>(UnrealTargetPlatform InPlatform, string InProjectName, string InPath, string InExecutableExtension)
            where T : StagedBuild
        {
            string BuildPath = InPath;

            List <T> DiscoveredBuilds = new List <T>();

            // Turn FooGame into just Foo as we need to check for client/server builds too
            string ShortName = Regex.Replace(InProjectName, "Game", "", RegexOptions.IgnoreCase);

            string ContentPath = Path.Combine(InPath, InProjectName, "Content", "Paks");

            if (Directory.Exists(ContentPath))
            {
                string EngineBinaryPath = Path.Combine(InPath, "Engine", "Binaries", InPlatform.ToString());
                string GameBinaryPath   = Path.Combine(InPath, InProjectName, "Binaries", InPlatform.ToString());

                // Executable will either be Project*.exe or for content-only UE4Game.exe
                string[] ExecutableMatches = new string[]
                {
                    ShortName + "*" + InExecutableExtension,
                    "UE4Game*" + InExecutableExtension,
                };

                // check
                // 1) Path/Project/Binaries/Platform
                // 2) Path (content only builds on some platforms write out a stub exe here)
                // 3) path/Engine/Binaries/Platform

                string[] ExecutablePaths = new string[]
                {
                    Path.Combine(InPath, InProjectName, "Binaries", InPlatform.ToString()),
                    //Path.Combine(InPath),
                    Path.Combine(InPath, "Engine", "Binaries", InPlatform.ToString()),
                };

                List <FileSystemInfo> Binaries = new List <FileSystemInfo>();

                foreach (var BinaryPath in ExecutablePaths)
                {
                    if (Directory.Exists(BinaryPath))
                    {
                        DirectoryInfo Di = new DirectoryInfo(BinaryPath);

                        foreach (var FileMatch in ExecutableMatches)
                        {
                            // Look at files & directories since apps on Mac are bundles
                            FileSystemInfo[] AppFiles = Di.GetFileSystemInfos(FileMatch);
                            Binaries.AddRange(AppFiles);
                        }
                    }
                }

                foreach (FileSystemInfo App in Binaries)
                {
                    UnrealTargetConfiguration Config = UnrealHelpers.GetConfigurationFromExecutableName(InProjectName, App.Name);
                    UnrealTargetRole          Role   = UnrealHelpers.GetRoleFromExecutableName(InProjectName, App.Name);

                    if (Config != UnrealTargetConfiguration.Unknown && Role != UnrealTargetRole.Unknown)
                    {
                        // store the exe path as relative to the staged dir path
                        T NewBuild = Activator.CreateInstance(typeof(T), new object[] { InPlatform, Config, Role, InPath, Utils.SystemHelpers.MakePathRelative(App.FullName, InPath) }) as T;

                        if (App.Name.StartsWith("UE4Game", StringComparison.OrdinalIgnoreCase))
                        {
                            NewBuild.Flags |= BuildFlags.ContentOnlyProject;
                        }

                        DiscoveredBuilds.Add(NewBuild);
                    }
                }
            }

            return(DiscoveredBuilds);
        }
 public static bool IsClient(this UnrealTargetRole Type)
 {
     return(Type == UnrealTargetRole.EditorGame || Type == UnrealTargetRole.Client);
 }
예제 #21
0
        /// <summary>
        /// Get a ConfigHierarchy of the type you want with platform-specific config for the given Role. This object can be used to read .ini config values.
        /// Default params return the client platform's game config.
        /// This looks for the workspace files for the project that you are trying to run your test on. The config directory for that project must exist to find valid results.
        /// </summary>
        public static ConfigHierarchy GetConfigHierarchy(UnrealTestContext TestContext, ConfigHierarchyType ConfigType = ConfigHierarchyType.Game, UnrealTargetRole TargetRole = UnrealTargetRole.Client)
        {
            string ProjectPath = Path.Combine(Environment.CurrentDirectory, TestContext.BuildInfo.ProjectName);

            if (!Directory.Exists(ProjectPath))
            {
                Log.Warning(string.Format("Directory does not exist at {0}! Returned ConfigHierarchy will not contain any config values. Make sure to sync the config directory for the project you are trying to run.", ProjectPath));
            }

            return(ConfigCache.ReadHierarchy(ConfigType, new DirectoryReference(ProjectPath), TestContext.GetRoleContext(TargetRole).Platform));
        }