public static void LogAndThrow(this AutomationException exception, [CallerMemberName] string testCaseName = null) { string debugDetailsFile = Path.Combine(VS.UiTestsDirectory, "TestErrors", typeof(UiTests).Name + "__" + testCaseName + "__DebugDetails.txt"); Directory.CreateDirectory(Path.GetDirectoryName(debugDetailsFile)); File.WriteAllText(debugDetailsFile, exception.ToString() + "\r\n" + exception.StackTrace + "\r\n" + exception.DebugDetails); throw exception; }
public static void LogAndThrow(this AutomationException exception, string typename, [CallerMemberName] string testCaseName = null) { string debugDetailsFile = Path.Combine(new Vs().UiTestsDirectory, "TestErrors", typename + "__" + testCaseName + "__DebugDetails.txt"); // ReSharper disable once AssignNullToNotNullAttribute Directory.CreateDirectory(Path.GetDirectoryName(debugDetailsFile)); File.WriteAllText(debugDetailsFile, exception + "\r\n" + exception.StackTrace + "\r\n" + exception.DebugDetails); throw exception; }
private void HandleError(TestContextStepPart stepPart) { var ex = new AutomationException( "failure while running {0} with parameters: [{1}]".AsFormat(stepPart.Name, stepPart.Parameters), stepPart.Exception); stepPart.Exception = ex; throw ex; }
private T TryAction <T>(Func <T> action) { var tries = 0; AutomationException lastException = null; while (tries < 5) { try { var result = action(); return(result); } catch (AutomationException e) { lastException = e; window = null; tries++; } } throw lastException; }
public void SetupVanillaVsExperimentalInstance(string suffix, string typename) { AskIfNotOnBuildServerAndProductiveVs(suffix); try { VisualStudioInstance = new VsExperimentalInstance(TestMetadata.Versions.VS2015, suffix); if (string.IsNullOrEmpty(suffix)) { _keepDirtyVsInstance = true; VisualStudioInstance.InstallExtension(_vsixPath); } else { if (!_keepDirtyVsInstance) { _keepDirtyVsInstance = AskToCleanIfExists(); } if (!_keepDirtyVsInstance) { VisualStudioInstance.FirstTimeInitialization(); VisualStudioInstance.InstallExtension(_vsixPath); } } } // ReSharper disable once RedundantCatchClause // ReSharper disable once UnusedVariable catch (Exception exception) { var wrapper = new AutomationException( $"Exception caught: {exception.GetType().Name}", exception.Message, exception); wrapper.LogAndThrow(typename); } }
private void RunResavePackagesCommandlet(ProjectParams Params) { Log("Running Step:- ResavePackages::RunResavePackagesCommandlet"); // Find the commandlet binary string UE4EditorExe = HostPlatform.Current.GetUE4ExePath(Params.UE4Exe); if (!FileExists(UE4EditorExe)) { LogError("Missing " + UE4EditorExe + " executable. Needs to be built first."); throw new AutomationException("Missing " + UE4EditorExe + " executable. Needs to be built first."); } // Now let's rebuild lightmaps for the project try { var CommandletParams = IsBuildMachine ? "-unattended -buildmachine -fileopenlog" : "-fileopenlog"; CommandletParams += " -AutoCheckOutPackages"; if (P4Enabled) { CommandletParams += String.Format(" -SCCProvider={0} -P4Port={1} -P4User={2} -P4Client={3} -P4Changelist={4} -P4Passwd={5}", "Perforce", P4Env.P4Port, P4Env.User, P4Env.Client, WorkingCL.ToString(), P4.GetAuthenticationToken()); } ResavePackagesCommandlet(Params.RawProjectPath, Params.UE4Exe, Params.MapsToRebuildLightMaps.ToArray(), CommandletParams); } catch (Exception Ex) { string FinalLogLines = "No log file found"; AutomationException AEx = Ex as AutomationException; if (AEx != null) { string LogFile = AEx.LogFileName; UnrealBuildTool.Log.TraceWarning("Attempting to load file {0}", LogFile); if (LogFile != "") { UnrealBuildTool.Log.TraceWarning("Attempting to read file {0}", LogFile); try { string[] AllLogFile = ReadAllLines(LogFile); FinalLogLines = "Important log entries\n"; foreach (string LogLine in AllLogFile) { if (LogLine.Contains("[REPORT]")) { FinalLogLines += LogLine + "\n"; } } } catch (Exception) { // we don't care about this because if this is hit then there is no log file the exception probably has more info LogError("Could not find log file " + LogFile); } } } // Something went wrong with the commandlet. Abandon this run, don't check in any updated files, etc. LogError("Resave Packages has failed. because " + Ex.ToString()); throw new AutomationException(ExitCode.Error_Unknown, Ex, "ResavePackages failed. {0}", FinalLogLines); } }